Bug 205334 - segmentation fault with gcj compiled 64-bit HelloWorld.java
segmentation fault with gcj compiled 64-bit HelloWorld.java
Status: CLOSED WORKSFORME
Product: Fedora
Classification: Fedora
Component: gcc4 (Show other bugs)
rawhide
ppc64 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-09-06 01:26 EDT by wzhou
Modified: 2007-11-30 17:11 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-09-08 06:08:17 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description wzhou 2006-09-06 01:26:27 EDT
Description of problem:

[woodzltc@localhost ~/bug15555/HelloWorld]$ gdb -q ./HelloWorld
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) r
Starting program: /home/woodzltc/bug15555/HelloWorld/HelloWorld
[Thread debugging using libthread_db enabled]
[New Thread 4398046707712 (LWP 16087)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 4398046707712 (LWP 16087)]
0x0000008081db2590 in .memset () from /lib64/libc.so.6
(gdb) bt
#0  0x0000008081db2590 in .memset () from /lib64/libc.so.6
#1  0x000000807547d25c in .GC_init_headers () from /usr/lib64/libgcj.so.7rh
#2  0x0000008075483c4c in .GC_init_inner () from /usr/lib64/libgcj.so.7rh
#3  0x0000008075483f80 in .GC_init () from /usr/lib64/libgcj.so.7rh
#4  0x000000807547c24c in .GC_init_gcj_malloc () from /usr/lib64/libgcj.so.7rh
#5  0x00000080748200f0 in ._Z10_Jv_InitGCv () from /usr/lib64/libgcj.so.7rh
#6  0x00000080747c4a74 in ._Z16_Jv_CreateJavaVMP14_Jv_VMInitArgs ()
   from /usr/lib64/libgcj.so.7rh
#7  0x00000080747c4ff4 in
._Z11_Jv_RunMainP14_Jv_VMInitArgsPN4java4lang5ClassEPKciPS6_b () from
/usr/lib64/libgcj.so.7rh
#8  0x00000080747c51b4 in ._Z11_Jv_RunMainPN4java4lang5ClassEPKciPS4_b ()
   from /usr/lib64/libgcj.so.7rh
#9  0x00000080747c5200 in .JvRunMain () from /usr/lib64/libgcj.so.7rh
#10 0x0000000010000bec in main (argc=1, argv=0xffffda5f938)
    at /tmp/cciRsHkS.i:11
(gdb)

Version-Release number of selected component (if applicable):
gcj (GCC) 4.1.1 20060802 (Red Hat 4.1.1-14)

How reproducible:
always

Steps to Reproduce:
1. see above HelloWorld.java testcase
2.
3.
  
Actual results:


Expected results:


Additional info:
 We found this during diagnosing why frysk segmentation fault on fc6 test2 ppc64.
Comment 1 wzhou 2006-09-06 01:29:34 EDT
Sorry, forget to attach the testcase.  it is simple though.

[woodzltc@localhost ~/bug15555/HelloWorld]$ cat HelloWorld.java
import java.util.*;

public class HelloWorld {
  public static void main (String[] args) {
    System.out.println ("Hello, world");
  }
}
[woodzltc@localhost ~/bug15555/HelloWorld]$ gcj -g -o HelloWorld HelloWorld.java
-lgcj -m64
Comment 2 wzhou 2006-09-06 01:39:46 EDT
The above case works ok on fc5 ppc64. It can print out "Hello, world".

One difference I notice is that: 

on fc5, it symbolly linked to /usr/lib/libgcj.so.7.0.0

$ ll /usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so
lrwxrwxrwx 1 root root 24 Jul  6 03:16
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so -> ../../../libgcj.so.7.0.0

on fc6, /usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so is linked to
/usr/lib64/libgcj.so.7rh.0.0

$ ll /usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so
lrwxrwxrwx 1 root root 35 Sep  3 06:05
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so ->
../../../../lib64/libgcj.so.7rh.0.0

this also make us fail to build HelloWorld.java into 32-bit binary:

$ gcj -g --main=HelloWorld -o HelloWorld  HelloWorld.java -lgcj
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so when searching for -lgcj
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so when searching for -lgcj
/usr/bin/ld: cannot find -lgcj
collect2: ld returned 1 exit status

Should we open another problem for this?

Comment 3 Jakub Jelinek 2006-09-08 06:08:17 EDT
Works just fine here, both for 32-bit and 64-bit build.
rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | egrep
'glibc|gcc|libgcj|zlib' | LC_ALL=C sort
gcc-4.1.1-20.ppc
gcc-c++-4.1.1-20.ppc
gcc-java-4.1.1-20.ppc
glibc-2.4.90-29.ppc
glibc-2.4.90-29.ppc64
glibc-common-2.4.90-29.ppc
glibc-devel-2.4.90-29.ppc
glibc-devel-2.4.90-29.ppc64
glibc-headers-2.4.90-29.ppc
libgcc-4.1.1-20.ppc
libgcc-4.1.1-20.ppc64
libgcj-4.1.1-20.ppc
libgcj-4.1.1-20.ppc64
libgcj-devel-4.1.1-20.ppc
libgcj-devel-4.1.1-20.ppc64
zlib-1.2.3-3.ppc
zlib-1.2.3-3.ppc64
zlib-devel-1.2.3-3.ppc
zlib-devel-1.2.3-3.ppc64
Comment 4 wzhou 2006-09-10 22:41:34 EDT
Odd!

For all the above packages, we are having the same versions.  But HelloWorld
still segm fault on my ppc64 box.  Don't know why.

Here is the output on our box:

rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | egrep
'glibc|gcc|libgcj|zlib' | LC_ALL=C sort
gcc-4.1.1-20.ppc
gcc-c++-4.1.1-20.ppc
gcc-gfortran-4.1.1-20.ppc
gcc-java-4.1.1-20.ppc
glibc-2.4.90-29.ppc
glibc-2.4.90-29.ppc64
glibc-common-2.4.90-29.ppc
glibc-devel-2.4.90-29.ppc
glibc-devel-2.4.90-29.ppc64
glibc-headers-2.4.90-29.ppc
jzlib-1.0.7-4jpp.1.ppc
libgcc-4.1.1-20.ppc
libgcc-4.1.1-20.ppc64
libgcj-4.1.1-20.ppc
libgcj-4.1.1-20.ppc64
libgcj-devel-4.1.1-20.ppc
libgcj-devel-4.1.1-20.ppc64
libgcj-src-4.1.1-20.ppc
zlib-1.2.3-3.ppc
zlib-1.2.3-3.ppc64
zlib-devel-1.2.3-3.ppc
zlib-devel-1.2.3-3.ppc64

The only difference I can notice is that we install gcc-fortran, jzlib and
libgcj-src packages. 

Will these extra packages make any difference?  Really curious.
Comment 5 wzhou 2006-09-10 22:48:34 EDT
Oh, Wait!

Do you meaned that HelloWorld can be built ok as 32-bit binary?  If yes, would
you please help me collect the outputs for the following commands?  Thanks a lot!

$ gcj --main=HelloWorld -g -o HelloWorld HelloWorld.java

$ gcj -v --main=HelloWorld -g -o HelloWorld HelloWorld.java

and 

$ ll /usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so


Here is what I get on my ppc64 box:

$ gcj --main=HelloWorld -g -o HelloWorld HelloWorld.java
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so when searching for -lgcj
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so when searching for -lgcj
/usr/bin/ld: cannot find -lgcj
collect2: ld returned 1 exit status

[woodzltc@localhost ~/bug15555/HelloWorld]$ gcj -v --main=HelloWorld -g -o
HelloWorld HelloWorld.java
Using built-in specs.
Reading specs from /usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.spec
rename spec startfile to startfileorig
rename spec lib to liborig
Target: ppc64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --enable-secureplt
--with-long-double-128 --host=ppc64-redhat-linux --build=ppc64-redhat-linux
--target=ppc64-redhat-linux --with-cpu=default32
Thread model: posix
gcc version 4.1.1 20060828 (Red Hat 4.1.1-20)
 /usr/libexec/gcc/ppc64-redhat-linux/4.1.1/jc1 HelloWorld.java
-fhash-synchronization -fuse-divide-subroutine -fuse-boehm-gc
-fnon-call-exceptions -fkeep-inline-functions -msecure-plt -quiet -dumpbase
HelloWorld.java -auxbase HelloWorld -g -version -o /tmp/ccUIEP6x.s
GNU Java version 4.1.1 20060828 (Red Hat 4.1.1-20) (ppc64-redhat-linux)
        compiled by GNU C version 4.1.1 20060828 (Red Hat 4.1.1-20).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Class path starts here:
    ./
    /usr/share/java/libgcj-4.1.1.jar/ (system) (zip)
 as -a32 -mppc -many -V -Qy -o /tmp/ccGMyie4.o /tmp/ccUIEP6x.s
GNU assembler version 2.17.50.0.3-3 (ppc-redhat-linux) using BFD version
2.17.50.0.3-3 20060715
 /usr/libexec/gcc/ppc64-redhat-linux/4.1.1/jvgenmain HelloWorldmain /tmp/ccQmz7vz.i
 /usr/libexec/gcc/ppc64-redhat-linux/4.1.1/cc1 /tmp/ccQmz7vz.i -msecure-plt
-quiet -dumpbase HelloWorldmain.c -g -version -fdollars-in-identifiers -o
/tmp/ccUIEP6x.s
GNU C version 4.1.1 20060828 (Red Hat 4.1.1-20) (ppc64-redhat-linux)
        compiled by GNU C version 4.1.1 20060828 (Red Hat 4.1.1-20).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 1e6dc6e3e62e6129edb11f335a991faa
 as -a32 -mppc -many -V -Qy -o /tmp/ccEbpwGa.o /tmp/ccUIEP6x.s
GNU assembler version 2.17.50.0.3-3 (ppc-redhat-linux) using BFD version
2.17.50.0.3-3 20060715
 /usr/libexec/gcc/ppc64-redhat-linux/4.1.1/collect2 --eh-frame-hdr -V -Qy -m
elf32ppclinux --hash-style=gnu -dynamic-linker /lib/ld.so.1 -o HelloWorld
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/../../../../lib/crt1.o
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/../../../../lib/crti.o
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/crtbegin.o
-L/usr/lib/gcc/ppc64-redhat-linux/4.1.1 -L/usr/lib/gcc/ppc64-redhat-linux/4.1.1
-L/usr/lib/gcc/ppc64-redhat-linux/4.1.1/../../../../lib -L/lib/../lib
-L/usr/lib/../lib /tmp/ccEbpwGa.o /tmp/ccGMyie4.o -lgcc_s -lgcc -lgcj -lm
-lpthread -lrt -lz -ldl -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/crtsavres.o
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/crtend.o
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/../../../../lib/crtn.o
GNU ld version 2.17.50.0.3-3 20060715
  Supported emulations:
   elf32ppclinux
   elf32ppc
   elf32ppcsim
   elf64ppc
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so when searching for -lgcj
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so when searching for -lgcj
/usr/bin/ld: cannot find -lgcj
collect2: ld returned 1 exit status

[woodzltc@localhost ~/bug15555/HelloWorld]$ ll
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so
lrwxrwxrwx 1 root root 35 Sep  6 02:48
/usr/lib/gcc/ppc64-redhat-linux/4.1.1/libgcj.so ->
../../../../lib64/libgcj.so.7rh.0.0
[woodzltc@localhost ~/bug15555/HelloWorld]$

Note You need to log in before you can comment on or make changes to this bug.