[Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch
matz at suse dot de
gcc-bugzilla@gcc.gnu.org
Mon May 23 16:51:00 GMT 2005
Below I attached a tarball which contains two packages with one class each.
B.java defines a static final String initilized to "foo", and A.java
tries to call the 'equals' method on that object (and another string).
This actually is reduced from trang. The problem happens when this is
compiled like the doit.sh script does. I.e. first creating the .class files
and then compiling both .class files at once into one object file with
-findirect-dispatch.
The generated program will segfault. The segfault happens because
the generated code for A.main() accesses the ->vtable member of the global
object '_ZN1b1B3FOOE' (== b::B::FOO) directly (if I read the .t03.generic dump
correctly). But it is defined like so in the assembler:
_ZN1b1B3FOOE:
.long _Utf1
.section .rodata.jutf8.10
I.e. the first (and only) member of that symbol actually is the UTF-8
string itself, not a pointer to the vtable. But the code trying to resolve
the address of the 'equals' method assumes so, and hence calls some random
address.
Note that this is not the same as the usual -findirect-dispatch only supports
compiling from .class problem. This is the case here.
--
Summary: gcj miscompiles accesses to static final vars with
indirect dispatch
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: matz at suse dot de
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
GCC target triplet: i686-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722
More information about the Gcc-bugs
mailing list