[Bug libgcj/13708] java program crashes at startup, UTF-8 environment

mec dot gnu at mindspring dot com gcc-bugzilla@gcc.gnu.org
Fri Jan 16 22:01:00 GMT 2004


------- Additional Comments From mec dot gnu at mindspring dot com  2004-01-16 22:01 -------
Subject: Re:  java program crashes at startup, UTF-8 environment

Here is some trace output to help illuminate the problem.
I wrote a simple gdb script, which, ironically, just simulates
printf debugging at some crucial points.

The first trace output is with an executable made with gcc HEAD
2004-01-09 17:10:00 UTC.  In the first trace output, these events occur:

  call _JvCreateJavaVM
  class initialize for java.lang.System
  constructor for java.io.PrintStream
  _Jv_Find_class call on gnu.gcj.convert.Output_UTF8
  initialization of java.lang.VMClassLoader.getSystemClassLoader

The second trace output is with an executable made with gcc HEAD
2004-01-15 13:08:06 UTC.  In the second trace output, these events
occur:

  call _JvCreateJavaVM
  initialization of java.lang.VMClassLoader.getSystemClassLoader
    class initialize for java.lang.System
    constructor for java.io.PrintStream
    _Jv_Find_class call on gnu.gcj.convert.Output_UTF8

In the second version, getSystemClassLoader is initialized early.
getSystemClassLoader uses j.l.System, which constructs an object
of type j.io.PrintStream, which calls _Jv_Find_class on
gnu.gcj.convert.Output_UTF8, which attempts to use the system class
loader ... which is still being initialized ... zero is returned for the
"sys" pointer and a segment fault happens.

(err, I just noticed I have a typo on _Jv_Find_class, sorry about that).

In the first version, j.io.PrintStream gets called before the first call
to getSystemClassLoader.  So when getSystemClassLoader runs for the
first time, it doesn't need to re-enter j.l.System, so it does not
re-enter _Jv_Find_class.

I would be very interested in seeing this output from Andrew's system:

  gdb a.out < findclass.gdbinit

=== trace with gcc HEAD 2004-01-09 17:10:00 UTC

GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) (gdb) (gdb) (gdb) (gdb) (gdb) Breakpoint 1 at 0x804c3d0: file /berman/fsf/shelf/2004-01-09-17-10-00/source/gcc/HEAD/gcc/libjava/prims.cc, line 895.
(gdb) >>>>(gdb) (gdb) Breakpoint 2 at 0x80859d1: file /berman/fsf/shelf/2004-01-09-17-10-00/source/gcc/HEAD/gcc/libjava/java/lang/VMClassLoader.java, line 280.
(gdb) >>>>(gdb) (gdb) Breakpoint 3 at 0x8085a90: file /berman/fsf/shelf/2004-01-09-17-10-00/source/gcc/HEAD/gcc/libjava/java/lang/VMClassLoader.java, line 300.
(gdb) >>>>(gdb) (gdb) Breakpoint 4 at 0x80829ee: file /berman/fsf/shelf/2004-01-09-17-10-00/source/gcc/HEAD/gcc/libjava/java/lang/System.java, line 78.
(gdb) >>>>(gdb) (gdb) Breakpoint 5 at 0x808adb6: file /berman/fsf/shelf/2004-01-09-17-10-00/source/gcc/HEAD/gcc/libjava/java/io/PrintStream.java, line 97.
(gdb) >>>>(gdb) (gdb) Breakpoint 6 at 0x808ad99: file /berman/fsf/shelf/2004-01-09-17-10-00/source/gcc/HEAD/gcc/libjava/java/io/PrintStream.java, line 118.
(gdb) >>>>(gdb) (gdb) Breakpoint 7 at 0x808ad4c: file /berman/fsf/shelf/2004-01-09-17-10-00/source/gcc/HEAD/gcc/libjava/java/io/PrintStream.java, line 142.
(gdb) >>>>(gdb) (gdb) Breakpoint 8 at 0x806ff05: file /berman/fsf/shelf/2004-01-09-17-10-00/source/gcc/HEAD/gcc/libjava/java/lang/natClassLoader.cc, line 480.
(gdb) >>>>(gdb) (gdb) Starting program: /berman/home/mec.gnu/gcc/findclass/jmisc.2004-01-09-17-10-00.exe 
[New Thread 8192 (LWP 22233)]
[Switching to Thread 8192 (LWP 22233)]
Current language:  auto; currently c++
break _JvCreateJavaVM
break _Jv_Find_class: java.lang.reflect.Field
Current language:  auto; currently java
break java.lang.System.<clinit>()
Current language:  auto; currently c++
break _Jv_Find_class: java.lang.Object
Current language:  auto; currently java
break java.io.PrintStream.PrintStream(java.io.OutputStream, boolean)
Current language:  auto; currently c++
break _Jv_Find_class: java.lang.Object
break _Jv_Find_class: gnu.gcj.convert.Output_UTF8
break _Jv_Find_class: java.security.Principal
Current language:  auto; currently java
break java.lang.VMClassLoader.getSystemClassLoader
Current language:  auto; currently c++
break _Jv_Find_class: java.net.URL
break _Jv_Find_class: java.lang.Object
break _Jv_Find_class: java.lang.String
break _Jv_Find_class: java.io.File
Current language:  auto; currently java
break java.lang.VMClassLoader.getSystemClassLoader:300
break java.io.PrintStream.PrintStream(java.io.OutputStream, boolean)
Current language:  auto; currently c++
break _Jv_Find_class: gnu.gcj.convert.Output_UTF8
[New Thread 16385 (LWP 22563)]
[New Thread 8194 (LWP 22564)]
break _Jv_Find_class: java.lang.String
break _Jv_Find_class: java.lang.Object
break _Jv_Find_class: java.lang.String
break _Jv_Find_class: java.lang.Object

Program exited normally.
(gdb) 

=== trace with gcc HEAD 2004-01-15 13:08:06 UTC

GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) (gdb) (gdb) (gdb) (gdb) (gdb) Breakpoint 1 at 0x804c3e0: file /berman/fsf/_today_/source/gcc/HEAD/gcc/libjava/prims.cc, line 895.
(gdb) >>>>(gdb) (gdb) Breakpoint 2 at 0x8087161: file /berman/fsf/_today_/source/gcc/HEAD/gcc/libjava/java/lang/VMClassLoader.java, line 280.
(gdb) >>>>(gdb) (gdb) Breakpoint 3 at 0x8087220: file /berman/fsf/_today_/source/gcc/HEAD/gcc/libjava/java/lang/VMClassLoader.java, line 300.
(gdb) >>>>(gdb) (gdb) Breakpoint 4 at 0x808417e: file /berman/fsf/_today_/source/gcc/HEAD/gcc/libjava/java/lang/System.java, line 78.
(gdb) >>>>(gdb) (gdb) Breakpoint 5 at 0x808c546: file /berman/fsf/_today_/source/gcc/HEAD/gcc/libjava/java/io/PrintStream.java, line 97.
(gdb) >>>>(gdb) (gdb) Breakpoint 6 at 0x808c529: file /berman/fsf/_today_/source/gcc/HEAD/gcc/libjava/java/io/PrintStream.java, line 118.
(gdb) >>>>(gdb) (gdb) Breakpoint 7 at 0x808c4dc: file /berman/fsf/_today_/source/gcc/HEAD/gcc/libjava/java/io/PrintStream.java, line 142.
(gdb) >>>>(gdb) (gdb) Breakpoint 8 at 0x8071675: file /berman/fsf/_today_/source/gcc/HEAD/gcc/libjava/java/lang/natClassLoader.cc, line 481.
(gdb) >>>>(gdb) (gdb) Starting program: /berman/home/mec.gnu/gcc/findclass/jmisc.today.exe 
[New Thread 8192 (LWP 32363)]
[Switching to Thread 8192 (LWP 32363)]
Current language:  auto; currently c++
break _JvCreateJavaVM
break _Jv_Find_class: java.lang.reflect.Field
break _Jv_Find_class: java.security.Principal
Current language:  auto; currently java
break java.lang.VMClassLoader.getSystemClassLoader
break java.lang.System.<clinit>()
Current language:  auto; currently c++
break _Jv_Find_class: java.lang.Object
Current language:  auto; currently java
break java.io.PrintStream.PrintStream(java.io.OutputStream, boolean)
Current language:  auto; currently c++
break _Jv_Find_class: gnu.gcj.convert.UnicodeToBytes
break _Jv_Find_class: java.lang.Object
break _Jv_Find_class: gnu.gcj.convert.Output_UTF8

Program received signal SIGSEGV, Segmentation fault.
_Jv_FindClass(_Jv_Utf8Const*, java::lang::ClassLoader*) (name=0x0, loader=0x0) at /berman/fsf/_today_/source/gcc/HEAD/gcc/libjava/java/lang/natClassLoader.cc:507
507		  klass = sys->loadClass (sname, false); 
(gdb) 

=== findclass.gdbinit

set height 0
set width 0

delete

break _Jv_CreateJavaVM
commands
silent
printf "break _JvCreateJavaVM\n"
continue
end

break 'java.lang.VMClassLoader.getSystemClassLoader()'
commands
silent
printf "break java.lang.VMClassLoader.getSystemClassLoader\n"
continue
end

break VMClassLoader.java:300
commands
silent
printf "break java.lang.VMClassLoader.getSystemClassLoader:300\n"
continue
end

break 'java.lang.System.<clinit>()'
commands
silent
printf "break java.lang.System.<clinit>()\n"
continue
end

break 'java.io.PrintStream.PrintStream(java.io.OutputStream)'
commands
silent
printf "break java.io.PrintStream.PrintStream(java.io.OutputStream)\n"
continue
end

break 'java.io.PrintStream.PrintStream(java.io.OutputStream, boolean)'
commands
silent
printf "break java.io.PrintStream.PrintStream(java.io.OutputStream, boolean)\n"
continue
end

break 'java.io.PrintStream.PrintStream(java.io.OutputStream, boolean, java.lang.String)'
commands
silent
printf "break java.io.PrintStream.PrintStream(java.io.OutputStream, boolean, java.lang.String)\n"
continue
end

break _Jv_FindClass
commands
silent
printf "break _Jv_Find_class: %s\n", (const char *) name->data
continue
end

run
quit


-- 


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



More information about the Gcc-bugs mailing list