public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: java/4766: Stack overflow when compiling .class file
@ 2001-11-13 19:13 Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2001-11-13 19:13 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR java/4766; it has been noted by GNATS.
From: Tom Tromey <tromey@redhat.com>
To: blanen@uinetworks.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: java/4766: Stack overflow when compiling .class file
Date: 19 Nov 2001 13:04:43 -0700
>>>>> "Blane" == blanen <blanen@uinetworks.com> writes:
Blane> If you put a return statement in a finally statement it will
Blane> cause a stack overflow.
I looked at this a little bit.
`gcj -C' generates this bytecode for your method:
0: getstatic #15=<Field java.lang.System.out java.io.PrintStream>
3: ldc #17=<String "x">
5: invokevirtual #23=<Method java.io.PrintStream.println (java.lang.String)void>
8: goto 16
11: astore_1
12: aload_1
13: invokevirtual #29=<Method java.lang.Throwable.printStackTrace ()void>
16: jsr 28
19: goto 35
22: astore_2
23: jsr 28
26: aload_2
27: athrow
28: astore_1
29: iconst_0
30: istore_3
31: iload_3
32: ireturn
33: ret 1
This code won't verify. Instruction 19 is a `goto' to an instruction
which doesn't exist.
Also, since the `finally' clause doesn't return, we probably shouldn't
be generating the jsr/ret pairs here. In the code above the `ret 1'
is dead, but `gcj --syntax-only' doesn't seem to notice.
FWIW javac generates this bytecode:
0: getstatic #10=<Field java.lang.System.out java.io.PrintStream>
3: ldc #1=<String "x">
5: invokevirtual #12=<Method java.io.PrintStream.println (java.lang.String)void>
8: goto 20
11: astore_1
12: aload_1
13: invokevirtual #11=<Method java.lang.Throwable.printStackTrace ()void>
16: goto 20
19: pop
20: iconst_0
21: ireturn
This seems much better.
So I think this report shows not only a verifier bug (plus which: the
gcj verifier doesn't seem to notice that the goto is out of bounds --
I didn't see any code in gcj to detect this situation), but also a few
bytecode generation problems.
Unfortunately I don't have time to fix this. A workaround is to
either use javac to compile bytecode in such cases, or just always
compile from .java->.o. The latter is preferable anyway.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: java/4766: Stack overflow when compiling .class file
@ 2001-12-20 21:14 tromey
0 siblings, 0 replies; 3+ messages in thread
From: tromey @ 2001-12-20 21:14 UTC (permalink / raw)
To: blanen, gcc-bugs, gcc-prs, java-prs, tromey
Synopsis: Stack overflow when compiling .class file
State-Changed-From-To: analyzed->closed
State-Changed-By: tromey
State-Changed-When: Thu Dec 20 21:13:58 2001
State-Changed-Why:
I've checked in the fix.
It will appear in gcj 3.1.
If you try it out, and have problems with it, tell me
and I will reopen this PR.
Thanks.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4766
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: java/4766: Stack overflow when compiling .class file
@ 2001-12-20 10:40 tromey
0 siblings, 0 replies; 3+ messages in thread
From: tromey @ 2001-12-20 10:40 UTC (permalink / raw)
To: blanen, gcc-bugs, gcc-prs, java-prs, nobody, tromey
Synopsis: Stack overflow when compiling .class file
Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Thu Dec 20 10:40:53 2001
Responsible-Changed-Why:
I'm handling this.
State-Changed-From-To: open->analyzed
State-Changed-By: tromey
State-Changed-When: Thu Dec 20 10:40:53 2001
State-Changed-Why:
I've submitted a patch:
http://gcc.gnu.org/ml/java-patches/2001-q4/msg00486.html
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4766
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-12-21 5:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-13 19:13 java/4766: Stack overflow when compiling .class file Tom Tromey
2001-12-20 10:40 tromey
2001-12-20 21:14 tromey
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).