public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch
@ 2005-05-23 16:51 matz at suse dot de
  2005-05-23 16:52 ` [Bug java/21722] " matz at suse dot de
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: matz at suse dot de @ 2005-05-23 16:51 UTC (permalink / raw)
  To: java-prs

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-06-03  5:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-23 16:51 [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch matz at suse dot de
2005-05-23 16:52 ` [Bug java/21722] " matz at suse dot de
2005-05-23 16:56 ` skh at suse dot de
2005-05-23 16:59 ` pinskia at gcc dot gnu dot org
2005-05-23 18:03 ` pinskia at gcc dot gnu dot org
2005-06-01 20:30 ` tromey at gcc dot gnu dot org
2005-06-01 20:59 ` matz at suse dot de
2005-06-01 21:36 ` tromey at gcc dot gnu dot org
2005-06-03  4:06 ` cvs-commit at gcc dot gnu dot org
2005-06-03  4:06 ` cvs-commit at gcc dot gnu dot org
2005-06-03  4:12 ` tromey at gcc dot gnu dot org
2005-06-03  5:34 ` tromey at gcc dot gnu dot org

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).