This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch: FYI: fix PR 29013
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 12 Sep 2006 12:54:03 -0600
- Subject: Patch: FYI: fix PR 29013
- Reply-to: tromey at redhat dot com
I'm checking this in.
This fixes PR 29013, a bug which causes us to emit invalid .class
files in one situation. The problem is that if we see a call to a
method which returns a value, but the value is ignored, then we don't
note the push of that value on the stack. In some code this can
result in the method having a stack overflow in the bytecode.
Tested on x86 FC5. New test case included.
I'm currently running all the gcj-generated bytecode through 'gcj
-fsyntax-only' to see if the verifier catches any other bytecode
generation bugs. There seems to be at least one.
Tom
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
PR java/29013:
* jcf-write.c (generate_bytecode_insns) <CALL_EXPR>: Always note
the push of the called method's return result.
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
PR java/29013:
* testsuite/libjava.lang/PR29013.out: Likewise.
* testsuite/libjava.lang/PR29013.java: New file.
Index: gcc/java/jcf-write.c
===================================================================
--- gcc/java/jcf-write.c (revision 116888)
+++ gcc/java/jcf-write.c (working copy)
@@ -2651,10 +2651,14 @@
if (TREE_CODE (f) != VOID_TYPE)
{
int size = TYPE_IS_WIDE (f) ? 2 : 1;
+ /* Always note the push here, so that we correctly
+ compute the required maximum stack size. */
+ NOTE_PUSH (size);
if (target == IGNORE_TARGET)
- emit_pop (size, state);
- else
- NOTE_PUSH (size);
+ {
+ emit_pop (size, state);
+ NOTE_POP (size);
+ }
}
break;
}
Index: libjava/testsuite/libjava.lang/PR29013.out
===================================================================
Index: libjava/testsuite/libjava.lang/PR29013.java
===================================================================
--- libjava/testsuite/libjava.lang/PR29013.java (revision 0)
+++ libjava/testsuite/libjava.lang/PR29013.java (revision 0)
@@ -0,0 +1,9 @@
+public class PR29013 {
+ public static int result() { return 5; }
+
+ public static void computeResult() { result(); }
+
+ public static void main(String[] args) {
+ computeResult();
+ }
+}