harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rana Dasgupta" <rdasg...@gmail.com>
Subject [drlvm]shutdown deadlock with gc.multithreads
Date Fri, 06 Apr 2007 00:38:35 GMT
On my 32 bit dual core machine running Win32 XP SP2, this test often
deadlocks on exit and hangs after printing "PASSED" on the console.
This happens often and I can break into it with the debugger. This
shows that the shutdown thread is deadlocked waiting for a semaphore
that has not been cleanly released, possibly by one of the threads
terminated( cancelled ) by the shutdown process.

Examples are the global mutex guarding hymutex_lock(&lib->TM_LOCK) in
countdown_nondaemon_threads() and elsewhere. Since TerminateThread is
an abrupt termination on Windows, this is certainly possible.

The Windows implementation of ExitProcess() uses an approach of
weakening all the critical sections after killing the threads to allow
the shutdown to continue, though this can of course expose some
inconsistent state to the shutdown thread. We can't do this, but as an
emulation, I created jthread_detach_shutdownthread() and
hythread_detach_shutdownthread() which are almost lock free. They are
only called by the shutdown thread very late when all the other
threads have exited and there can be no races.  I attach this in


Maybe Weldon and others working on fixing threading can consider
whether we want to take this approach.  If so, I can clean up the
patch and verify it  on Linux where we don't have the problem due to
cleaner thread cancellation. Adding a hythread function is also a
little messy and needs a little more cleanup that is worth doing only
if the approach makes sense.


View raw message