GCJ application runs not too bad with shared libs, but crashes with static libs - seems to be in _Jv_MonitorEnter
Scott Gilbertson
scottg@mantatest.com
Thu Nov 21 14:34:00 GMT 2002
I figured out how to get a core file (ulimit -c unlimited), and I've tried
that with the offending application.
Now I'm seeing about the same thing every time it crashes, up to about #17
in the backtrace below.
If I'm reading this right, it means a SEGV happened in _IO_vfscanf,
ultimately called from _Jv_MonitorEnter because of a "synchronized".
I added the following code at startup, which has significantly reduced the
frequency of crashes (presumably by reducing the time spent in
System.out.println), but hasn't eliminated them.
java.io.OutputStream os = new java.io.OutputStream()
{
public void write (int b) throws java.io.IOException
{
}
};
System.setOut ( new java.io.PrintStream(os) );
It looks to me like there's a race condition somewhere in the "synchronized"
handling, perhaps due to a bug in glibc.
Ideas?
Has anyone else seen crashes while calling println or other synchronized
methods from the event dispatch thread?
I assume the problem is happening on the first call to the spin function in
natObject, because that's the only time it calls is_mp. I'm thinking that
the reason the crash happens more easily when statically linked is due to a
timing difference, but that the dynamic executable probably has the same
basic problem.
Here's a relavent exerpt from java/lang/natObject.cc. I'm considering a
hack, making it always return false, just for testing.
// Try to determine whether we are on a multiprocessor, i.e. whether
// spinning may be profitable.
// This should really use a suitable autoconf macro.
// False is the conservative answer, though the right one is much
better.
static bool
is_mp()
{
#ifdef _SC_NPROCESSORS_ONLN
long nprocs = sysconf(_SC_NPROCESSORS_ONLN);
return (nprocs > 1);
#else
return false;
#endif
}
And here's the backtrace
#0 0x08168c11 in kill ()
#1 0x0815583a in raise ()
#2 0x08168f6d in abort ()
#3 0x080a7214 in _Jv_Throw (value=0x83ecff0)
at ../../../gcc/libjava/exception.cc:110
#4 0x0809d5bc in catch_segv (_dummy=138334192)
at ../../../gcc/libjava/prims.cc:112
#5 0x0809d5d1 in catch_segv(int) () at ../../../gcc/libjava/prims.cc:121
#6 <signal handler called>
#7 0x081a3d2d in _IO_vfscanf ()
#8 0x08190b2d in vsscanf ()
#9 0x0819086d in sscanf ()
#10 0x08192dd0 in getmntent_r ()
#11 0x0817ced0 in get_proc_path ()
#12 0x0817ccc6 in get_nprocs_conf ()
#13 0x080bdf95 in is_mp () at
../../../gcc/libjava/java/lang/natObject.cc:320
#14 0x080bdfba in spin (n=0) at
../../../gcc/libjava/java/lang/natObject.cc:512
#15 0x080be585 in _Jv_MonitorEnter (obj=0x83f3fa8)
at ../../../gcc/libjava/java/lang/natObject.cc:812
#16 0x080cfc7b in java.io.PrintStream.print(java.lang.String, boolean) (
this=0x83f3fa8, str=0x8457680, println=true)
at ../../../gcc/libjava/java/io/PrintStream.java:70
#17 0x080d01a0 in java.io.PrintStream.println(java.lang.String) (
---Type <return> to continue, or q <return> to quit---
this=0x83f3fa8, str=0x8457680)
at ../../../gcc/libjava/java/io/PrintStream.java:219
#18 0x08085da2 in
manta::mts5000::application::MainPanel$MyPanel::paint(java::aw
t::Graphics*) ()
#19 0x080ee80e in
java.awt.Component.processPaintEvent(java.awt.event.PaintEvent
) (this=0x8458420, event=0x845da08)
at ../../../gcc/libjava/java/awt/Component.java:2062
#20 0x080ed779 in java.awt.Component.dispatchEventImpl(java.awt.AWTEvent) (
this=0x8458420, e=0x845da08)
at ../../../gcc/libjava/java/awt/Component.java:1501
#21 0x080ed610 in java.awt.Component.dispatchEvent(java.awt.AWTEvent) (
this=0x8458420, e=0x845da08)
at ../../../gcc/libjava/java/awt/Component.java:1456
#22 0x0813fb20 in java.awt.EventDispatchThread.run() (this=0x83f7a28)
at ../../../gcc/libjava/java/awt/EventDispatchThread.java:65
#23 0x080c27d9 in _Jv_ThreadRun(java::lang::Thread*) (thread=0x83f7a28)
at ../../../gcc/libjava/java/lang/natThread.cc:285
More information about the Java
mailing list