Bug 12708

Summary: SIGSEGV, Segmentation fault starting java program
Product: gcc Reporter: Pekka Järveläinen <pj>
Component: libgcjAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: minor CC: bryce, gcc-bugs, gyanendra.webmaster, java-prs
Priority: P2    
Version: 3.3.2   
Target Milestone: ---   
Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu
Build: pentium4-pc-linux-gnu Known to work:
Known to fail: Last reconfirmed:

Description Pekka Järveläinen 2003-10-21 13:02:52 UTC
SIGSEGV, Segmentation fault starting java program

Steps to Reproduce
run my program

Actual Results:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1082393760 (LWP 5300)]
java.lang.String.endsWith(java.lang.String) (this=@80f2e40, suffix=null)
    at ../../../gcc-3.3.2/libjava/java/lang/String.java:264
264         return regionMatches (this.count - suffix.count, suffix, 0,
suffix.count);
Current language:  auto; currently java
(gdb) where
#0  java.lang.String.endsWith(java.lang.String) (this=@80f2e40, suffix=null)
    at ../../../gcc-3.3.2/libjava/java/lang/String.java:264
#1  0x40420e26 in gnu.gcj.runtime.VMClassLoader.<clinit>() ()
    at ../../../gcc-3.3.2/libjava/gnu/gcj/runtime/VMClassLoader.java:36
#2  0x4039e6f9 in java::lang::Class::initializeClass() (this=@4068d600)
    at ../../../gcc-3.3.2/libjava/java/lang/natClass.cc:814
#3  0x40552b9c in _Jv_InitClass (klass=null) at Class.h:265
#4  0x403b4e3f in java.lang.ClassLoader.getSystemClassLoader() ()
    at ../../../gcc-3.3.2/libjava/java/lang/ClassLoader.java:203
#5  0x4039d125 in java::lang::Class::getClassLoader() (this=null)
    at ../../../gcc-3.3.2/libjava/java/lang/natClass.cc:134
#6  0x4039d0a9 in java::lang::Class::forName(java::lang::String*) (
    className=null) at ../../../gcc-3.3.2/libjava/java/lang/natClass.cc:104
#7  0x4036728a in gnu.gcj.convert.UnicodeToBytes.getDefaultEncoder() ()
    at ../../../gcc-3.3.2/libjava/gnu/gcj/convert/UnicodeToBytes.java:49
#8  0x403de634 in java.io.PrintStream.PrintStream(java.io.OutputStream, boolean)
    (this=@1, out=null)
    at ../../../gcc-3.3.2/libjava/java/io/PrintStream.java:241
#9  0x403c428a in java.lang.System.<clinit>() ()
    at ../../../gcc-3.3.2/libjava/java/lang/System.java:135
#10 0x4039e6f9 in java::lang::Class::initializeClass() (this=@80a3658)
    at ../../../gcc-3.3.2/libjava/java/lang/natClass.cc:814
#11 0x40552b9c in _Jv_InitClass (klass=null) at Class.h:265
#12 0x403c3bac in java.lang.System.getProperty(java.lang.String) (key=@1)
    at ../../../gcc-3.3.2/libjava/java/lang/System.java:393
#13 0x403c6ebe in java.lang.Throwable.<clinit>() ()
    at ../../../gcc-3.3.2/libjava/java/lang/Throwable.java:403
#14 0x4039e6f9 in java::lang::Class::initializeClass() (this=@80a3658)
    at ../../../gcc-3.3.2/libjava/java/lang/natClass.cc:814
#15 0x4039e735 in java::lang::Class::initializeClass() (this=@80a3658)
    at Class.h:265
#16 0x4039e735 in java::lang::Class::initializeClass() (this=@80a3658)
    at Class.h:265
#17 0x4039e735 in java::lang::Class::initializeClass() (this=@80a3658)
    at Class.h:265
#18 0x4037ec31 in _Jv_AllocObjectNoFinalizer (klass=@80a3658, size=20)
    at Class.h:265
#19 0x4037ec6c in _Jv_AllocObject (klass=@1, size=0)
    at ../../../gcc-3.3.2/libjava/prims.cc:431
#20 0x4037fa69 in _Jv_CreateJavaVM(void*) ()
    at ../../../gcc-3.3.2/libjava/prims.cc:937
#21 0x4037fc6f in _Jv_RunMain(java::lang::Class*, char const*, int, char
const**, bool) (klass=@8094200, name=null, argc=1, argv=@bfffdbe4, is_jar=false)
    at ../../../gcc-3.3.2/libjava/prims.cc:989
#22 0x4037fe29 in JvRunMain (klass=null, argc=0, argv=null)
    at ../../../gcc-3.3.2/libjava/prims.cc:1027
#23 0x0804de61 in main (argc=0, argv=null) at /tmp/ccYcsffb.i:11
#24 0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6

Expected Results:
Database connection or error message

Build Date & Platform
2003-10-21 RedHat Linux 9 pentium 4 PC
uname -a
Linux rubiini.csc.fi 2.4.20-20.9smp #1 SMP Mon Aug 18 11:32:15 EDT 2003 i686
i686 i386 GNU/Linux 
gcc compiled make CFLAGS='-O3 -march=pentium4 -mcpu=pentium4' LIBCFLAGS='-g -O3
-march=pentium4' LIBCXXFLAGS='-g -O3 -march=pentium4 -fno-implicit-templates'
GCJFLAGS='-g -O3 -march=pentium4 -mcpu=pentium4' bootstrap
by gcc 3.3.1

Additional Information:
Originally there was problem with gcc 3.3.1
 ./a.out
Exception in thread "main" java.lang.ExceptionInInitializerError
   at java.lang.Class.initializeClass()
(/mnt/mds/linux22_i386/lang/gcc/3.3.1rh9/lib/libgcj.so.4.0.0)
   at _Jv_InitClass (/mnt/mds/linux22_i386/lang/gcc/3.3.1rh9/lib/libgcj.so.4.0.0)
   at net.sourceforge.jtds.jdbc.EncodingHelper.getHelper(java.lang.String)
(Unknown Source)
   at net.sourceforge.jtds.jdbc.Tds.setCharset(java.lang.String) (Unknown Source)
   at net.sourceforge.jtds.jdbc.Tds.Tds(net.sourceforge.jtds.jdbc.TdsConnection,
java.util.Properties) (Unknown Source)
   at net.sourceforge.jtds.jdbc.TdsConnection.allocateTds(boolean) (Unknown Source)
   at
net.sourceforge.jtds.jdbc.TdsConnection.TdsConnection(java.util.Properties)
(Unknown Source)
   at net.sourceforge.jtds.jdbc.Driver.connect(java.lang.String,
java.util.Properties) (Unknown Source)
   at java.sql.DriverManager.getConnection(java.lang.String,
java.util.Properties) (/mnt/mds/linux22_i386/lang/gcc/3.3.1rh9/lib/libgcj.so.4.0.0)
   at java.sql.DriverManager.getConnection(java.lang.String, java.lang.String,
java.lang.String) (/mnt/mds/linux22_i386/lang/gcc/3.3.1rh9/lib/libgcj.so.4.0.0)
   at Askare.getConnection() (Unknown Source)
   at tietoni_en.main(java.lang.String[]) (Unknown Source)
Caused by: java.io.CharConversionException
   at gnu.gcj.convert.Input_iconv.read(char[], int, int)
(/mnt/mds/linux22_i386/lang/gcc/3.3.1rh9/lib/libgcj.so.4.0.0)
   at java.lang.String.init(byte[], int, int, java.lang.String) (/mnt/mds/linux22_
Optimization level of main program has no effect, program compiled for example
/v/gcc/3.3.2/bin/gcj -save-temps -g --main=tietoni_en tietoni_en.java *.o
where *.o is 
http://jtds.sourceforge.net/
Comment 1 Bryce McKinlay 2003-10-21 22:38:34 UTC
This looks like a runtime initialization problem. Class.forName(), and subsequently, VMClassLoader 
is being called from inside _Jv_CreateJavaVM, but the File.separator field has not yet been set.

1. Does a "hello world" program work ok? 

2. Can you try this with the current CVS code?

3. Can you narrow this problem down to a small test case?
Comment 2 Pekka Järveläinen 2003-10-22 07:27:16 UTC
Subject: Re:  SIGSEGV, Segmentation fault starting java
	program

On ke, 2003-10-22 at 01:38, bryce at mckinlay dot net dot nz wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12708
> ------- Additional Comments From bryce at mckinlay dot net dot nz  2003-10-21 22:38 -------
> This looks like a runtime initialization problem. Class.forName(), and subsequently, VMClassLoader 
> is being called from inside _Jv_CreateJavaVM, but the File.separator field has not yet been set.
> 
> 1. Does a "hello world" program work ok? 

No, same error. Good Question! I was stupid to not tested myself.

> 2. Can you try this with the current CVS code?

No, I tried, but I seems to have difficulties to compile it:
-I../../gcc/gcc/ada ../../gcc/gcc/ada/gnat1drv.adb -o ada/gnat1drv.o
gnatbind -C -I- -I. -Iada -I../../gcc/gcc/ada -o ada/b_gnat1.c -n
ada/gnat1drv.ali
fatal error: file gnat1drv.ali is incorrectly formatted
make sure you are using consistent versions of gcc/gnatbind
9.   R nnvvnnnnnnnnnvvvnnvnvvnnnnnnnnnvnvnnnnnnnvvvnnnnvvnn
                                                     |
make[2]: *** [ada/b_gnat1.c] Error 4
make[2]: Leaving directory `/tmp/pj/cvs/objdir/gcc'
make[1]: *** [stage1_build] Error 2
make[1]: Leaving directory `/tmp/pj/cvs/objdir/gcc'
make: *** [bootstrap] Error 2

I can try again with other configuration options if you like. 

> 3. Can you narrow this problem down to a small test case?

Yes!
 cat > HelloWorld.java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World!");
}
}
[pj@rubiini pj]$ /v/linux22_i386/lang/gcc/3.3.2/bin/gcj
--main=HelloWorld -g -o HelloWorld HelloWorld.java
[pj@rubiini pj]$ ./HelloWorld 
Väärä muistilohko (muistin tila talletettu)
oops my LANG was fi_FI
setenv LANG en_EN
./HelloWorld
Segmentation fault (core dumped)

I'm compiling gcc again with -march=i686 instead of pentium4 

Comment 3 Bryce McKinlay 2003-10-22 08:28:42 UTC
Subject: Re:  SIGSEGV, Segmentation fault starting java program

>> 1. Does a "hello world" program work ok?
>
> No, same error. Good Question! I was stupid to not tested myself.

OK, so it must be something caused by your configuration or 
environment. What linux distribution is this on? And are you using the 
distribution's gcj or did you compile it yourself?

>> 2. Can you try this with the current CVS code?
>
> No, I tried, but I seems to have difficulties to compile it:
> -I../../gcc/gcc/ada ../../gcc/gcc/ada/gnat1drv.adb -o ada/gnat1drv.o
> gnatbind -C -I- -I. -Iada -I../../gcc/gcc/ada -o ada/b_gnat1.c -n
> ada/gnat1drv.ali
> fatal error: file gnat1drv.ali is incorrectly formatted
> make sure you are using consistent versions of gcc/gnatbind

Try configuring with --enable-languages=java - this will only build the 
C, C++, and java compilers so problems with ada will be avoided (and 
the build will go a bit faster)

FYI my configure command is:

./configure --prefix=/home/bryce/gcc --enable-languages=java 
--enable-java-awt=gtk --disable-static

Comment 4 Pekka Järveläinen 2003-10-22 08:53:35 UTC
Subject: Re:  SIGSEGV, Segmentation fault starting java
	program

On ke, 2003-10-22 at 11:29, bryce at mckinlay dot net dot nz wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12708

> OK, so it must be something caused by your configuration or 
> environment. What linux distribution is this on? 

It's RedHat 9 with all updates:
uname -a
Linux rubiini.csc.fi 2.4.20-20.9smp #1 SMP Mon Aug 18 11:32:15 EDT 2003
i686 i686 i386 GNU/Linux

> And are you using the 
> distribution's gcj or did you compile it yourself?

I compiled myself. I'll try cvs again.

Comment 5 Pekka Järveläinen 2003-10-22 10:48:50 UTC
Subject: Re:  SIGSEGV, Segmentation fault starting java
	program

On ke, 2003-10-22 at 11:29, bryce at mckinlay dot net dot nz wrote:
> Try configuring with --enable-languages=java - this will only build the 
> C, C++, and java compilers so problems with ada will be avoided (and 
> the build will go a bit faster)

It helps but:

../../../gcc/libiberty/fibheap.c: In function `fibheap_delete_node':
 
../../../gcc/libiberty/fibheap.c:285: error: `LONG_MIN' undeclared
(first use in this function)
../../../gcc/libiberty/fibheap.c:285: error: (Each undeclared identifier
is reported only once
../../../gcc/libiberty/fibheap.c:285: error: for each function it
appears in.)
make[2]: *** [fibheap.o] Error 1
make[2]: Leaving directory
`/tmp/pj/cvs/objdir/i686-pc-linux-gnu/libiberty'
make[1]: *** [all-target-libiberty] Error 2
make[1]: Leaving directory `/tmp/pj/cvs/objdir'
make: *** [bootstrap] Error 2

Comment 6 Bryce McKinlay 2003-10-22 10:59:10 UTC
Subject: Re:  SIGSEGV, Segmentation fault starting java program

On Oct 22, 2003, at 11:49 PM, pj at csc dot fi wrote:

> ../../../gcc/libiberty/fibheap.c: In function `fibheap_delete_node':
>
> ../../../gcc/libiberty/fibheap.c:285: error: `LONG_MIN' undeclared
> (first use in this function)
> ../../../gcc/libiberty/fibheap.c:285: error: (Each undeclared 
> identifier
> is reported only once
> ../../../gcc/libiberty/fibheap.c:285: error: for each function it
> appears in.)
> make[2]: *** [fibheap.o] Error 1

Well, something is very wrong here - looks like a problem with your 
system/glibc headers?

Comment 7 Pekka Järveläinen 2003-10-22 11:14:46 UTC
Subject: Re:  SIGSEGV, Segmentation fault starting java
	program

On ke, 2003-10-22 at 13:59, bryce at mckinlay dot net dot nz wrote:

> Well, something is very wrong here - looks like a problem with your 
> system/glibc headers?

Not very wrong because I can compile 3.3.2 (but it don't work with java)
The compilation problem is only with cvs version.
There can be something wrong, I'll try other computer, which is upgraded
to 9 from RedHat 8. 

Comment 8 Pekka Järveläinen 2003-10-22 12:16:19 UTC
Subject: Re:  SIGSEGV, Segmentation fault starting java
	program

On ke, 2003-10-22 at 13:59, bryce at mckinlay dot net dot nz wrote:

> Well, something is very wrong here - looks like a problem with your 
> system/glibc headers?

No, if I compile gcc 3.3.2 by command
make CFLAGS='-O2' LIBCFLAGS='-g -O2' LIBCXXFLAGS='-g -O2
-fno-implicit-templates' bootstrap 
HelloWorld works well but if I use
make CFLAGS='-O3 -march=i686 -mcpu=pentium4' LIBCFLAGS='-g -O3
-march=i686 -mcpu=pentium4' LIBCXXFLAGS='-g -O3 -march=i686 
-mcpu=pentium4 -fno-implicit-templates' bootstrap
it failes to start.

cvs version failed to compile also other Redhat 9 machine.

Comment 9 Andrew Pinski 2003-10-22 17:11:16 UTC
What version of binutils do you have?
From <http://gcc.gnu.org/install/specific.html#ix86-*-linux*>:
As of GCC 3.3, binutils 2.13.1 or later is required for this platform. See bug 10877 for more 
information.
Comment 10 Bryce McKinlay 2003-10-22 21:48:30 UTC
Subject: Re:  SIGSEGV, Segmentation fault starting java program

RHL 9 ships with binutils 2.13.90 so I doubt this would be a problem.

Pekka, regarding your build problem, I build CVS GCC at least every few 
days on an RHL 9 system (and Im sure many others do), so the build 
error must have something to do with your environment or the commands 
you are using to build GCC.

FYI I build gcc using

cd cvs/gcc
mkdir build
cd build
../configure --prefix=/home/bryce/gcc --enable-languages=java 
--enable-java-awt=gtk --disable-static
make

The compiler you are using to build/bootstrap can also cause problems, 
make sure you are using redhat's compiler or a known-good GCC 3.3.x 
build in your path.


Comment 11 Pekka Järveläinen 2003-10-23 07:00:57 UTC

*** This bug has been marked as a duplicate of 10877 ***
Comment 12 Giovanni Bajo 2003-12-06 13:57:22 UTC
reopen this bug because...
Comment 13 Giovanni Bajo 2003-12-06 13:57:55 UTC
it's a duplicate of a different bug.

*** This bug has been marked as a duplicate of 13334 ***
Comment 14 Gyan Ojha 2012-02-07 10:55:36 UTC
This Driver version is error free,DataDirect free trial downloads for JDBC drivers, ODBC drivers and ADO.NET providers including connection to Oracle, DB2, Sybase, and MS SQL Server. Download it from: http://www.datadirect.com/products/jdbc/index.html