public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: java/8955: switch case statement causes gcj to throw segmentation fault
@ 2002-12-18 5:26 Gary Benson
0 siblings, 0 replies; 6+ messages in thread
From: Gary Benson @ 2002-12-18 5:26 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR java/8955; it has been noted by GNATS.
From: Gary Benson <gbenson@redhat.com>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, bhun@chello.nl,
gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, java-prs@gcc.gnu.org
Cc:
Subject: Re: java/8955: switch case statement causes gcj to throw segmentation fault
Date: Wed, 18 Dec 2002 13:23:43 +0000
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8955
If you want a smaller testcase, the following hangs gcc 3.2 (from Red
Hat Linux 8.0) when invoked as 'gcj -C Test.java':
/* Test.java */
public class Test
{
void foo()
{
switch(1) {
case Other.FOO:
break;
case Other.BAR:
break;
}
}
}
/* Other.java */
public class Other
{
static final int FOO = Integer.MIN_VALUE;
static final int BAR = 1;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: java/8955: switch case statement causes gcj to throw segmentation fault
@ 2002-12-20 11:29 tromey
0 siblings, 0 replies; 6+ messages in thread
From: tromey @ 2002-12-20 11:29 UTC (permalink / raw)
To: bhun, gcc-bugs, gcc-prs, java-prs, tromey
Synopsis: switch case statement causes gcj to throw segmentation fault
State-Changed-From-To: analyzed->closed
State-Changed-By: tromey
State-Changed-When: Fri Dec 20 11:29:15 2002
State-Changed-Why:
I've checked in the fix.
It will appear in gcj 3.3.
If you can try it, please do; if there is still a problem
I'll reopen the PR.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8955
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: java/8955: switch case statement causes gcj to throw segmentation fault
@ 2002-12-19 11:35 tromey
0 siblings, 0 replies; 6+ messages in thread
From: tromey @ 2002-12-19 11:35 UTC (permalink / raw)
To: bhun, gcc-bugs, gcc-prs, java-prs, nobody, tromey
Synopsis: switch case statement causes gcj to throw segmentation fault
Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Thu Dec 19 11:35:07 2002
Responsible-Changed-Why:
I'm handling this.
This is on the fix list for 3.3.
State-Changed-From-To: open->analyzed
State-Changed-By: tromey
State-Changed-When: Thu Dec 19 11:35:07 2002
State-Changed-Why:
I've submitted a patch.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8955
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: java/8955: switch case statement causes gcj to throw segmentation fault
@ 2002-12-19 1:56 Gary Benson
0 siblings, 0 replies; 6+ messages in thread
From: Gary Benson @ 2002-12-19 1:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR java/8955; it has been noted by GNATS.
From: Gary Benson <gbenson@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: bhun@chello.nl, gcc-gnats@gcc.gnu.org
Subject: Re: java/8955: switch case statement causes gcj to throw segmentation fault
Date: Thu, 19 Dec 2002 09:53:23 +0000
On Wed, Dec 18, 2002 at 06:34:49PM -0700, Tom Tromey wrote:
> >>>>> ">" == Dhek Bhun Kho <bhun@chello.nl> writes:
>
> >> Number: 8955
> >> Synopsis: switch case statement causes gcj to throw segmentation
> >> fault
>
> Could you try the appended patch?
Works for me, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: java/8955: switch case statement causes gcj to throw segmentation fault
@ 2002-12-18 17:36 Tom Tromey
0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2002-12-18 17:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR java/8955; it has been noted by GNATS.
From: Tom Tromey <tromey@redhat.com>
To: bhun@chello.nl
Cc: gcc-gnats@gcc.gnu.org, Gary Benson <gbenson@redhat.com>
Subject: Re: java/8955: switch case statement causes gcj to throw segmentation fault
Date: 18 Dec 2002 18:34:49 -0700
>>>>> ">" == Dhek Bhun Kho <bhun@chello.nl> writes:
>> Number: 8955
>> Synopsis: switch case statement causes gcj to throw segmentation fault
Could you try the appended patch?
gcj 3.3 crashed on Gary's reduced test case. The appended patch fixes
that.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* jcf-write.c (generate_bytecode_insns) [SWITCH_EXPR]: Handle case
where minimum case value is Integer.MIN_VALUE.
Fixes PR java/8955.
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.111
diff -u -r1.111 jcf-write.c
--- jcf-write.c 16 Dec 2002 18:22:35 -0000 1.111
+++ jcf-write.c 19 Dec 2002 01:29:59 -0000
@@ -1746,6 +1746,7 @@
else
{
HOST_WIDE_INT i;
+ unsigned HOST_WIDE_INT delta;
/* Copy the chain of relocs into a sorted array. */
struct jcf_relocation **relocs = (struct jcf_relocation **)
xmalloc (sw_state.num_cases * sizeof (struct jcf_relocation *));
@@ -1778,8 +1779,11 @@
handled by the parser. */
}
- if (2 * sw_state.num_cases
- >= sw_state.max_case - sw_state.min_case)
+ /* We could have DELTA < 0 if sw_state.min_case is
+ something like Integer.MIN_VALUE. That is why delta is
+ unsigned. */
+ delta = sw_state.max_case - sw_state.min_case;
+ if (2 * sw_state.num_cases >= delta)
{ /* Use tableswitch. */
int index = 0;
RESERVE (13 + 4 * (sw_state.max_case - sw_state.min_case + 1));
^ permalink raw reply [flat|nested] 6+ messages in thread
* java/8955: switch case statement causes gcj to throw segmentation fault
@ 2002-12-15 22:06 bhun
0 siblings, 0 replies; 6+ messages in thread
From: bhun @ 2002-12-15 22:06 UTC (permalink / raw)
To: gcc-gnats
>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:
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-12-20 19:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-18 5:26 java/8955: switch case statement causes gcj to throw segmentation fault Gary Benson
-- strict thread matches above, loose matches on Subject: below --
2002-12-20 11:29 tromey
2002-12-19 11:35 tromey
2002-12-19 1:56 Gary Benson
2002-12-18 17:36 Tom Tromey
2002-12-15 22:06 bhun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).