Bug 13948

Summary: [3.4 Regression] GCJ segmentation fault while compiling GL4Java .class files
Product: gcc Reporter: Max Gilead <gilead>
Component: javaAssignee: Not yet assigned to anyone <unassigned>
Severity: critical CC: gcc-bugs, java-prs, rmathew
Priority: P2 Keywords: ice-on-valid-code, patch
Version: 3.4.0   
Target Milestone: 3.4.3   
Host: Target:
Build: Known to work: 3.3.1 4.0.0
Known to fail: 3.4.0 Last reconfirmed: 2004-01-31 20:02:53
Bug Depends on:    
Bug Blocks: 17574    
Attachments: gl4java/GL4JavaInitException.java

Description Max Gilead 2004-01-31 13:46:44 UTC
When trying to compile GL4Java project .class files into native code GCJ crashes.

I prepared minimal test case.

Command I issue and its result:
max@maxbox:~/gl4java_test$ gcj -v -save-temps --classpath ${LIBGCJ} -shared -o
libgl4java.so gl4java/GL4JavaInitException.class gl4java/GLRunnable.class
Reading specs from /home/max/gcc34/out/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Reading specs from
rename spec lib to liborig
Configured with: ../gcc/configure --prefix=/home/max/gcc34/out --with-system-zlib
Thread model: posix
gcc version 3.4.0 20040125 (prerelease)
 /home/max/gcc34/out/libexec/gcc/i686-pc-linux-gnu/3.4.0/jc1 /tmp/ccgrrBzxjx
-fhash-synchronization -fno-use-divide-subroutine -fuse-boehm-gc
-fnon-call-exceptions -fkeep-inline-functions -quiet -dumpbase ccgrrBzxjx
-mtune=pentiumpro -auxbase ccgrrBzxjx -g1 -version -fclasspath=-shared
-ffilelist-file -o ccgrrBzxjx.s
GNU Java version 3.4.0 20040125 (prerelease) (i686-pc-linux-gnu)
        compiled by GNU C version 3.3.3 20040110 (prerelease) (Debian).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64465
Class path starts here:
    /home/max/gcc34/out/share/java/libgcj-3.4.0.jar/ (system) (zip)
gl4java/GL4JavaInitException.class:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Contents of ccgrrBzxjx.s generated temp file:
        .file   "ccgrrBzxjx"
        .section        .debug_abbrev,"",@progbits
        .section        .debug_info,"",@progbits
        .section        .debug_line,"",@progbits

I'm using GCC obtained from CVS gcc-3_4-branch on 2004.01.25

GCJ version:

max@maxbox:~/gl4java_test$ gcj --version
gcj (GCC) 3.4.0 20040125 (prerelease)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
max@maxbox:~/gl4java_test$ uname -a
Linux maxbox 2.4.24-1-686 #1 Tue Jan 6 21:29:44 EST 2004 i686 GNU/Linux

I'll be happy to provide any help which would aid in resolving this problem.
Comment 1 Max Gilead 2004-01-31 13:47:28 UTC
Created attachment 5627 [details]
Comment 2 Max Gilead 2004-01-31 13:47:56 UTC
Created attachment 5628 [details]
Comment 3 Max Gilead 2004-01-31 13:48:20 UTC
Created attachment 5629 [details]
Comment 4 Max Gilead 2004-01-31 13:48:43 UTC
Created attachment 5630 [details]
Comment 5 Andrew Pinski 2004-01-31 20:02:51 UTC
I can reproduce this.  The command line which I can reproduce this with:
gcj -o libgl4java.so gl4java/GL4JavaInitException.class gl4java/GLRunnable.class
Note you have include "-o filename" part else it will not seg fault.
Comment 6 Andrew Pinski 2004-02-01 14:12:58 UTC
Here is the backtrace:
#0  add_miranda_methods (base_class=0x40c6aa80, search_class=0x40c6ac80) at /Users/
#1  0x0002a4c4 in add_miranda_methods (base_class=0x40c6aa80, search_class=0x40c6ac80) at 
#2  0x0002a3ac in layout_class_methods (this_class=0x40c6aa80) at /Users/pinskia/src/gcc-
#3  0x0000d354 in java_layout_seen_class_methods () at /Users/pinskia/src/gcc-checkin/src/gcc/
#4  0x000463d4 in parse_class_file () at /Users/pinskia/src/gcc-checkin/src/gcc/java/jcf-parse.c:
#5  0x00047550 in java_parse_file (set_yydebug=1086761600) at /Users/pinskia/src/gcc-
#6  0x0005c198 in toplev_main (argc=1078371988, argv=0x4046a694) at /Users/pinskia/src/
#7  0x00002534 in _start (argc=17, argv=0xbffffb7c, envp=0xbffffbc4) at /SourceCache/Csu/
#8  0x000023a8 in start ()
Comment 7 Andrew Pinski 2004-02-01 14:17:20 UTC
Confirmed a regression from 3.3.1.
Comment 8 Mark Mitchell 2004-03-01 01:49:51 UTC
Java problems are not showstoppers, so I have pushed this back to GCC 3.4.1.
Comment 9 Ranjit Mathew 2004-05-03 05:49:40 UTC
Yet another Miranda methods bug!

FWIW, for me it happens *only* if I say:

gcj -shared -o libgl4java.so gl4java/GL4JavaInitException.class

It *does not happen* if I:

  1. Omit the "-o" flag (as Andrew Pinski points out).
  2. Use Java sources instead of class files.
  3. Reverse the order of the classes on the command line.
Comment 10 Anthony Green 2004-05-30 22:58:13 UTC
I've hit the same bug building Ant 1.6.1 from rhug.  It happens while building
bytecode from org/apache/tools/ant/types/selectors/BaseSelectorContainer.java.

(gdb) where
#0  0x080bcd93 in add_miranda_methods (base_class=0xf6d27244,
    at /home/green/sources/jhbuild-src/gcc/gcc/java/class.c:2067
#1  0x080bd05b in add_miranda_methods (base_class=0xf6d27244,
    at /home/green/sources/jhbuild-src/gcc/gcc/java/class.c:2108
#2  0x080bd57a in layout_class_methods (this_class=0xf6d27244)
    at /home/green/sources/jhbuild-src/gcc/gcc/java/class.c:2140
#3  0x080bd397 in layout_class_methods (this_class=0xf66cf740)
    at /home/green/sources/jhbuild-src/gcc/gcc/java/class.c:2127
#4  0x080710a5 in java_layout_seen_class_methods () at parse.y:7587
#5  0x0807141e in java_layout_classes () at parse.y:7652
#6  0x08078a26 in java_expand_classes () at parse.y:9001
#7  0x080efb6f in java_parse_file (set_yydebug=0)
    at /home/green/sources/jhbuild-src/gcc/gcc/java/jcf-parse.c:1111
#8  0x08486e28 in compile_file ()
    at /home/green/sources/jhbuild-src/gcc/gcc/toplev.c:1653
#9  0x08488769 in do_compile ()
    at /home/green/sources/jhbuild-src/gcc/gcc/toplev.c:2699
#10 0x084887d0 in toplev_main (argc=19, argv=0xfeef1e84)
    at /home/green/sources/jhbuild-src/gcc/gcc/toplev.c:2731
#11 0x0810a90e in main (argc=19, argv=0xfeef1e84)
    at /home/green/sources/jhbuild-src/gcc/gcc/main.c:35

Comment 11 Mark Mitchell 2004-06-09 19:31:02 UTC
Postponed until 3.4.2.
Comment 12 Ranjit Mathew 2004-06-14 19:19:38 UTC
My proposed patch is here:

Comment 13 CVS Commits 2004-06-17 13:45:31 UTC
Subject: Bug 13948

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rmathew@gcc.gnu.org	2004-06-17 13:45:24

Modified files:
	gcc/java       : ChangeLog parse.y jcf-parse.c 

Log message:
	Fixes PR java/13948
	* parse.y (java_layout_seen_class_methods): Ensure class is loaded
	before trying to lay out its methods.
	* jcf-parse.c (read_class): Track parsed files using canonical paths
	obtained via lrealpath from libiberty.
	(java_parse_file): Likewise.
	(parse_source_file_1): Rename formal parameter to reflect its
	modified purpose. Minor formatting fix.


Comment 14 Anthony Green 2004-06-29 16:58:22 UTC
I have the patch installed, but I'm still seeing the same failure in ant.
Comment 15 Ranjit Mathew 2004-06-30 04:48:14 UTC
(In reply to comment #14)
> I have the patch installed, but I'm still seeing the same failure in ant.

Are you using the latest CVS sources? Bryce also fixed a couple of class
loading bugs recently (after the fix above went in). If the problem still
persists, can you at least give the backtrace with a "debug_tree()" of
the class that is causing problems?

Comment 16 Mark Mitchell 2004-08-23 20:54:47 UTC
Postponed until GCC 3.4.3.
Comment 17 Tom Tromey 2004-09-23 17:19:07 UTC
I can build the rhug ant just fine with current cvs head.
I'm closing this; I'll ping Anthony to see if he still has problems.