User account creation filtered due to spam.

Bug 23300 - DECL_FIELD_OFFSET == 0 versus build_field_ref
Summary: DECL_FIELD_OFFSET == 0 versus build_field_ref
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Tom Tromey
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: 18131
  Show dependency treegraph
 
Reported: 2005-08-09 19:30 UTC by Tom Tromey
Modified: 2005-08-16 16:08 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 3.4.0 3.0.4 3.3.3 4.0.0 4.1.0
Last reconfirmed: 2005-08-15 19:38:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2005-08-09 19:30:01 UTC
If I copy the current cvs classpath into the libjava build directory
and try to build, I get an ICE.

The problem occurs because of this code in build_field_ref:

      if (! flag_syntax_only
	  && (flag_indirect_dispatch
	      /* DECL_FIELD_OFFSET == 0 if we have no reference for
		 the field, perhaps because we couldn't find the class
		 in which the field is defined.  
		 FIXME: We should investigate this.  */
	      || DECL_FIELD_OFFSET (field_decl) == 0))

... flag_indirect_dispatch is false, but we have DECL_FIELD_OFFSET==0
for a 'this$0' field.  So, we wind up using the indirect dispatch code
anyway.  This causes a later crash (we build a bogus tree since the
otable is NULL).

I haven't investigated why DECL_FIELD_OFFSET can be 0 here.
Comment 1 Tom Tromey 2005-08-10 23:11:45 UTC
Here's the failure:

/home/tromey/Merge/build/gcc/gcj
-B/home/tromey/Merge/build/i686-pc-linux-gnu/libjava/
-B/home/tromey/Merge/build/gcc/ -ffloat-store -fclasspath=
-fbootclasspath=/home/tromey/Merge/build/i686-pc-linux-gnu/libjava/classpath/lib
--encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -c -MT javax/swing.lo
-MD -MP -MF javax/swing.deps @javax/swing.list -fPIC -o javax/.libs/swing.o
../../../gcc/libjava/classpath/javax/swing/JPasswordField.java: In class
'javax.swing.JPasswordField$AccessibleJPasswordField':
../../../gcc/libjava/classpath/javax/swing/JPasswordField.java: In constructor
'(javax.swing.JPasswordField)':
../../../gcc/libjava/classpath/javax/swing/JPasswordField.java:61: internal
compiler error: Segmentation fault
Comment 2 Andrew Pinski 2005-08-11 01:58:20 UTC
[21:55] < pinskia> tromey: it is hitting class.c:2151
[21:55] < pinskia> which is causing the class not to be layout at all

Here is the backtrace:
#0  layout_class (this_class=0xb7cda78c) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/java/
class.c:2151
#1  0x0805646d in safe_layout_class (class=0x0) at parse.y:5637
#2  0x0809047e in maybe_layout_super_class (super_class=0xb7cda78c, this_class=0xb795e398)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/java/class.c:2068
#3  0x08095f5d in layout_class (this_class=0xb795e398) at /home/peshtigo/pinskia/src/gnu/gcc/src/
gcc/java/class.c:2147
#4  0x080d482e in read_class (name=0xb795d1e0) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/
java/jcf-parse.c:608
#5  0x080d4c82 in load_class (class_or_name=0xb795d1e0, verbose=1) at /home/peshtigo/pinskia/
src/gnu/gcc/src/gcc/java/jcf-parse.c:682
#6  0x080d5163 in load_inner_classes (cur_class=Variable "cur_class" is not available.
) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/java/jcf-parse.c:821
#7  0x080d4835 in read_class (name=0xb7952118) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/
java/jcf-parse.c:609
#8  0x080d4c82 in load_class (class_or_name=0xb7950284, verbose=1) at /home/peshtigo/pinskia/
src/gnu/gcc/src/gcc/java/jcf-parse.c:682
#9  0x080903d0 in maybe_layout_super_class (super_class=0xb7950284, this_class=0xb795033c)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/java/class.c:2070
#10 0x08095f5d in layout_class (this_class=0xb795033c) at /home/peshtigo/pinskia/src/gnu/gcc/
src/gcc/java/class.c:2147
#11 0x080d482e in read_class (name=0xb794f2a8) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/
java/jcf-parse.c:608
#12 0x080d4c82 in load_class (class_or_name=0xb794f2a8, verbose=0) at /home/peshtigo/pinskia/
src/gnu/gcc/src/gcc/java/jcf-parse.c:682
#13 0x08068e2f in do_resolve_class (enclosing=Variable "enclosing" is not available.
) at parse.y:6026
#14 0x080691b0 in resolve_class (enclosing=0xb78fe958, class_type=0xb7907a6c, 
decl=0xb790de88, cl=0xb790de60) at parse.y:5850
#15 0x080695a3 in jdep_resolve_class (dep=0x991b660) at parse.y:5652
#16 0x08069d41 in java_complete_class () at parse.y:5703
#17 0x080d4a6c in read_class (name=0xb790be38) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/
java/jcf-parse.c:575
#18 0x080d4c82 in load_class (class_or_name=0xb790be38, verbose=0) at /home/peshtigo/pinskia/
src/gnu/gcc/src/gcc/java/jcf-parse.c:682
#19 0x08068e2f in do_resolve_class (enclosing=Variable "enclosing" is not available.
) at parse.y:6026
#20 0x080691b0 in resolve_class (enclosing=0xb7aad6e8, class_type=0xb7ab7f74, 
decl=0xb7ac2000, cl=0xb7ac1898) at parse.y:5850
#21 0x080695a3 in jdep_resolve_class (dep=0x9915b00) at parse.y:5652
#22 0x08069d41 in java_complete_class () at parse.y:5703
#23 0x080d4a6c in read_class (name=0xb7ab3500) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/
java/jcf-parse.c:575
#24 0x080d4c82 in load_class (class_or_name=0xb7ab3500, verbose=0) at /home/peshtigo/pinskia/
src/gnu/gcc/src/gcc/java/jcf-parse.c:682
#25 0x08068e2f in do_resolve_class (enclosing=Variable "enclosing" is not available.
) at parse.y:6026
#26 0x080691b0 in resolve_class (enclosing=0xb7d1db60, class_type=0xb7d5e508, 
decl=0xb7d5f730, cl=0xb7d5f6e0) at parse.y:5850
#27 0x080695a3 in jdep_resolve_class (dep=0x9832060) at parse.y:5652
#28 0x08069d41 in java_complete_class () at parse.y:5703
#29 0x080d4a6c in read_class (name=0xb7d216b8) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/
java/jcf-parse.c:575
#30 0x080d4c82 in load_class (class_or_name=0xb7d1f228, verbose=0) at /home/peshtigo/pinskia/
src/gnu/gcc/src/gcc/java/jcf-parse.c:682
#31 0x08068780 in do_resolve_class (enclosing=0xb7cb1138, import_type=0x0, 
class_type=0xb7cd1bdc, decl=0x0, cl=Variable "cl" is not available.
) at parse.y:6030
#32 0x08068642 in do_resolve_class (enclosing=Variable "enclosing" is not available.
) at parse.y:3717
#33 0x080691b0 in resolve_class (enclosing=0xb7cb1138, class_type=0xb7cd1bdc, 
decl=0xb7cb1138, cl=0xb7cd5f78) at parse.y:5850
#34 0x080695a3 in jdep_resolve_class (dep=0x97faa80) at parse.y:5652
#35 0x08069d41 in java_complete_class () at parse.y:5703
#36 0x080d5d21 in java_parse_file (set_yydebug=0) at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/
java/jcf-parse.c:1280
#37 0x0839cd60 in toplev_main (argc=0, argv=0xbfea4624) at /home/peshtigo/pinskia/src/gnu/gcc/
src/gcc/toplev.c:971
#38 0x003e7ad4 in __libc_start_main () from /lib/tls/libc.so.6
#39 0x08049cd1 in _start ()


I cannot debug it further as I debugging with an optimized compiled.
Comment 3 Andrew Pinski 2005-08-11 02:01:35 UTC
This is definetly not a regression.
Before 4.0.0, we got:
javax/swing/AbstractButton.java: In class `javax.swing.AbstractButton$AccessibleAbstractButton':
javax/swing/AbstractButton.java: In method `(javax.swing.AbstractButton)':
javax/swing/AbstractButton.java:2011: Internal compiler error in expand_expr, at expr.c:6865
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
Comment 4 Andrew Pinski 2005-08-11 02:39:45 UTC
More information, maybe_layout_super_class is returning NULL.

the Supper class is SynchronizedCollection.

This is for java.util.Collections$SynchronizedSet.

Which means we have a couple of issues like this.

do_resolve_class in maybe_layout_super_class is returning null.
Comment 5 Andrew Pinski 2005-08-11 02:59:19 UTC
Huh, read_class is failing for java.util.SynchronizedCollection.
Comment 6 Andrew Pinski 2005-08-11 03:06:27 UTC
(In reply to comment #5)
> Huh, read_class is failing for java.util.SynchronizedCollection.

Woops I was stupid, that should fail.

Comment 7 Andrew Pinski 2005-08-11 03:37:24 UTC
Hmm, I think we are not looking into the class's outer class's supper class but I don't know how to 
prove this.
Comment 8 Ranjit Mathew 2005-08-11 11:38:39 UTC
(In reply to comment #2)
> 
> 
> I cannot debug it further as I debugging with an optimized compiled.

  cd $GCC_SRC_DIR/gcc/java
  touch class.c parse.y
  cd $GCC_BLD_DIR
  make BOOT_CFLAGS='-g3 -O0' bubblestrap

http://gcc.gnu.org/wiki/DebuggingGCC
Comment 9 Tom Tromey 2005-08-15 19:38:49 UTC
I submitted a patch.
Comment 10 CVS Commits 2005-08-16 16:07:00 UTC
Subject: Bug 23300

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2005-08-16 16:06:44

Modified files:
	gcc/java       : ChangeLog class.c expr.c 

Log message:
	PR java/23300.
	* expr.c (build_field_ref): Don't generate otable reference when
	DECL_FIELD_OFFSET is 0.
	* class.c (maybe_layout_super_class): Pass outer class to
	do_resolve_class.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1655&r2=1.1656
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/class.c.diff?cvsroot=gcc&r1=1.237&r2=1.238
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/expr.c.diff?cvsroot=gcc&r1=1.234&r2=1.235

Comment 11 Tom Tromey 2005-08-16 16:08:49 UTC
I checked in a fix to the trunk.