Class loader blocking on multithreaded systems?

alanlb at access.rrinc.com alanlb at access.rrinc.com
Fri Jun 4 07:10:28 PDT 1999


Hello, folks.

I've spent the past few days investigating a case where the BeOS port,
which employs native threads, fails to run to completion.  Specifically,
the failure occurs with the "ClassGC" test in the regression suite, and
does not happen with every run (ie, it is thread execution
order-dependent).

"ps" tells me that there are at least two different failure modes
possible.  In mode #1, only the main thread and finaliser thread remain,
with the main thread waiting for the finaliser to exit, and the finaliser
waiting on a condition variable X.  In mode #2, which I haven't looked at
as much, the main thread, gc and finaliser threads remain, with the main
thread and gc both waiting on the same condition variable Y, and the
finaliser waiting on condition variable X.

The sequence of events for mode #1 is as follows:

1) The main thread performs jthread_exit, and seeing that the only other
   threads left are daemons, iterates through the thread list.
   For each daemon thread, the main thread:

      a. sends the daemon thread a STOP signal
      b. waits for the daemon thread to exit

2) The gc thread receives the STOP signal, executes the onstop() handler,
   which amounts to throwing a ThreadDeath exception.  Eventually, the
   gc thread jthread_exit()s without incident.

3) The finaliser thread receives the STOP signal, executes the onstop()
   handler and throws a ThreadDeath exception.  However, instead of
   jumping to a point from which it invokes jthread_exit(), the finaliser
   thread ends up waiting to acquire a class lock.

The output from running kaffe with "-v" suggests that in mode #2, kaffe 
blocks while loading java/lang/ThreadDeath.class, whereas in mode #1,
kaffe gets a little further, but blocks soon after that.

I'd like to know if anyone working with the other multithreaded ports
(OSKit, Linux Pthreads) has encountered problems with the "ClassGC" test.
Also, any hints or suggestions as to what I might look for would be
welcome.  For the moment, I'm baffled...

Alan





More information about the kaffe mailing list