This is the mail archive of the java-prs@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

java/8955: switch case statement causes gcj to throw segmentation fault


>Number:         8955
>Category:       java
>Synopsis:       switch case statement causes gcj to throw segmentation fault
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 15 22:06:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Dhek Bhun Kho
>Release:        gcc 3.2.1
>Organization:
>Environment:

>Description:
gcc version 3.2 (Mandrake Linux 9.0 3.2-1mdk)
 /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/jc1 /tmp/ccEJu2L1jx -quiet -dumpbase ccEJu2L1jx -g1 -version -foutput-class-dir=cls -fclasspath=/home/java/jar/javax.xml.parsers.jar:src/ -ffilelist-file -fsyntax-only -femit-class-files -o /dev/null
GNU Java version 3.2 (Mandrake Linux 9.0 3.2-1mdk) (i586-mandrake-linux-gnu)
	compiled by GNU C version 3.2 (Mandrake Linux 9.0 3.2-1mdk).
Class path starts here:
    /home/java/jar/javax.xml.parsers.jar/ (zip)
    src/
    /usr/share/java/libgcj-3.2.jar/ (system) (zip)
src/org/apache/log4j/Level.java: In class `org.apache.log4j.Level':
src/org/apache/log4j/Level.java: In method `org.apache.log4j.Level.toLevel(int,org.apache.log4j.Level)':
src/org/apache/log4j/Level.java:104: internal error: Segmentation fault

-- is this related to the symbol table problem with c compiler? or is related to opcodes of the jvm? I read that bytecodes differ for ranges without gaps and with gaps, this is one with gaps series: 10000-20000-30000-40000 (int)


>How-To-Repeat:
compile Log4J

offending code:  Level toLevel(int val, Level defaultLevel) {
    switch(val) {
    case ALL_INT: return ALL;
    case DEBUG_INT: return Level.DEBUG;
    case INFO_INT: return Level.INFO;
    case WARN_INT: return Level.WARN;
    case ERROR_INT: return Level.ERROR;
    case FATAL_INT: return Level.FATAL;
    case OFF_INT: return OFF;
    default: return defaultLevel;
    }


>Fix:
replace switch-case with if-ifelse-ifelse-ifelse-ifelse-else:

e.g:
    if (val==ALL_INT) return ALL; 
    else if (val==DEBUG_INT) return Level.DEBUG;
    else if (val==INFO_INT) return Level.INFO;
    else if (val==WARN_INT) return Level.WARN;
    else if (val==ERROR_INT) return Level.ERROR;
    else if (val==FATAL_INT) return Level.FATAL;
    else if (val==OFF_INT) return OFF;
    else return defaultLevel;
  }

causes no segmentation fault.
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]