* DevNotes: Add entry cgf-000017.

* _cygtls.cc (_cygtls::call2): Use new exit_thread function in place of
ExitThread.
* miscfuncs.cc (thread_wrapper): Ditto.
* thread.cc (pthread::exit): Ditto.
(pthread_mutex::unlock): Set tid to NULL rather than 0.
(pthread_spinlock::unlock): Ditto.
* pinfo.cc (commune_process): Actually call lock_process constructor.
* sigproc.cc (exit_thread): New function.
(wait_sig): Handle __SIGTHREADEXIT case.  Don't just block rather than
returning from this function.
* sigproc.h (__SIGTHREADEXIT): New enum.
(exit_thread): Declare.
* sync.cc (muto::release): Accept a tls command-line argument.
* sync.h (muto::release): Accept a tls command-line parameter.  Default to
&_my_tls.
This commit is contained in:
Christopher Faylor
2012-12-21 18:52:00 +00:00
parent dfbb1d0383
commit 614aff88a0
10 changed files with 106 additions and 13 deletions

View File

@@ -1,3 +1,27 @@
2012-12-21 cgf-000017
The changes in this set are to work around the issue noted here:
http://cygwin.com/ml/cygwin/2012-12/threads.html#00140
The problem is, apparently, that the return value of an ExitThread()
will take precedence over the return value of TerminateProcess/ExitProcess
if the thread is the last one exiting. That's rather amazing...
For the fix, I replaced all calls to ExitThread with exit_thread(). The
exit_thread function, creates a handle to the current thread and sends
it to a packet via sig_send(__SIGTHREADEXIT). Then it acquires the
process lock and calls ExitThread.
wait_sig will then wait for the handle, indicating that the thread has
exited, and, when that has happened, remove the process lock on behalf
of the now-defunct thread. wait_sig will now also avoid actually
exiting since it could trigger the same problem.
Holding process_lock should prevent threads from exiting while a Cygwin
process is shutting down. They will just block forever in that case -
just like wait_sig.
2012-08-17 cgf-000016
While debugging another problem I finally noticed that