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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  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 ` matz at suse dot de
  2005-05-23 16:56 ` skh at suse dot de
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: matz at suse dot de @ 2005-05-23 16:52 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From matz at suse dot de  2005-05-23 16:52 -------
Created an attachment (id=8953)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8953&action=view)
tarball showing the problem


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  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
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: skh at suse dot de @ 2005-05-23 16:56 UTC (permalink / raw)
  To: java-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |skh at suse dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  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
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-23 16:59 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-23 16:59 -------
Related to PR 1259.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |1259


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  2005-05-23 16:51 [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch matz at suse dot de
                   ` (2 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-23 18:03 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-23 18:03 -------
Confirmed, I don't get a seg fault but a NPE (NullPointerException) instead.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-05-23 18:03:47
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  2005-05-23 16:51 [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch matz at suse dot de
                   ` (3 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-01 20:30 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-01 20:30 -------
Interestingly, if I compile the two .class files separately
and then link the results, it works.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  2005-05-23 16:51 [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch matz at suse dot de
                   ` (4 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: matz at suse dot de @ 2005-06-01 20:59 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From matz at suse dot de  2005-06-01 20:59 -------
Yes.  I think this is because the compiler needs to see the definition and the use site 
to exhibit this bug.  Without the def it will correctly emit the code walking the table 
to get to the member. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  2005-05-23 16:51 [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch matz at suse dot de
                   ` (5 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-01 21:36 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-01 21:36 -------
I'm testing a patch.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tromey at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-05-23 18:03:47         |2005-06-01 21:36:08
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  2005-05-23 16:51 [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch matz at suse dot de
                   ` (7 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-03  4:06 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-03 04:06 -------
Subject: Bug 21722

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2005-06-03 04:06:19

Modified files:
	gcc/java       : ChangeLog class.c 

Log message:
	PR java/21722:
	* class.c (build_static_field_ref): Don't fold constant fields if
	current class is from a .class file and we're using indirect
	dispatch.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1621&r2=1.1622
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/class.c.diff?cvsroot=gcc&r1=1.230&r2=1.231



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  2005-05-23 16:51 [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch matz at suse dot de
                   ` (6 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-03  4:06 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-03 04:06 -------
Subject: Bug 21722

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tromey@gcc.gnu.org	2005-06-03 04:05:53

Modified files:
	gcc/java       : ChangeLog class.c 

Log message:
	PR java/21722:
	* class.c (build_static_field_ref): Don't fold constant fields if
	current class is from a .class file and we're using indirect
	dispatch.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1556.2.22&r2=1.1556.2.23
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/class.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.220.8.2&r2=1.220.8.3



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  2005-05-23 16:51 [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch matz at suse dot de
                   ` (8 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-03  4:12 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-03 04:12 -------
I've checked in the fix for this.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21722


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

* [Bug java/21722] gcj miscompiles accesses to static final vars with indirect dispatch
  2005-05-23 16:51 [Bug java/21722] New: gcj miscompiles accesses to static final vars with indirect dispatch matz at suse dot de
                   ` (9 preceding siblings ...)
  2005-06-03  4:12 ` tromey at gcc dot gnu dot org
@ 2005-06-03  5:34 ` tromey at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-03  5:34 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-03 05:34 -------
Forgot to mark as fixed earlier.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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