jthread deadlock again

Godmar Back gback at marker.cs.utah.edu
Wed May 26 12:49:06 PDT 1999


> 
> I'm trying to get my multi-threaded server application (a servlet engine) up
> and running with Kaffe on BSDI BSD 2.1. Besides being multi-threaded the
> socket connections are multiplexed, so I'm making use of a lot of threads.  
> My application periodically freezes up while doing socket IO.  I believe I
> am running into the "jthread deadlock" problem described in
> http://rufus.w3.org/tools/Kaffe/messages/4906.html and
> http://rufus.w3.org/tools/Kaffe/messages/4914.html.  This application runs
> fine with the Sun JDK on Windows and RH Linux.
> 
> I'm wondering if anybody has done any work on this problem, can tell me
> anything more about it, or has a patch that I could try out.
> 

Hmmm.
What I'd do is to use gdb, interrupt it when it gets stuck in select
and look at the backtraces of all threads to see where they are.

You may be able to adapt the livethreads and restorethread macros
in gdbinit for that purpose (especially restorethread should be easy
for you, given that you've implemented setjmp yourself!)
Use the jitwhere macro and/or findnativemethod to find out where you
got stuck.

The second thing you should do is to check whether your system actually
delivers SIGIO properly.  I guess you could print it out.

Third, you should check that you actually get stuck in select() as
opposed to in the read from the helper pipe.   Note the hack we put in
for systems that don't send SIGIO on write buffer restoration, such
as FreeBSD.  For those systems, we poll every so often to see if an
fd was become writable.

Finally, another possible problem may be that your system deadlocks for
other reasons (a deadlock in your application, less likely, a deadlock
in Kaffe's runtime libs, more likely), but that this deadlock goes
undetected because you have threads that are waiting for input.
The way Kaffe's jthread detects a deadlock is by checking whether the
number of threads that are waiting for external events such as I/O or
timers is zero at the time when we suspend Kaffe in select.


	- Godmar


More information about the kaffe mailing list