diff options
author | Christopher Faylor <me@cgf.cx> | 2012-12-21 23:32:43 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2012-12-21 23:32:43 +0400 |
commit | 65068ebd7f78c461f2e5b59e49ac923f98783ab1 (patch) | |
tree | 88f76df0beb9b66918bcce690aaa5df7d14ef39f /winsup/cygwin/init.cc | |
parent | 614aff88a0cf6c0ec5ec5ba063b003549dedc9db (diff) |
* DevNotes: Add entry cgf-000018.
* init.cc (dll_entry): Grab process lock before exiting to ensure that thread
doesn't exit before parent if parent is exiting.
* _cygtls.cc (_cygtls::call2): Revert previous 2012-12-21 change.
* miscfuncs.cc (thread_wrapper): Ditto.
* thread.cc (pthread::exit): Ditto.
* sigproc.cc (exit_thread): Ditto.
(wait_sig): Ditto.
* sync.cc (muto::release): Ditto.
* sync.h (muto::release): Ditto.
* sigproc.h (__SIGTHREADEXIT): Delete enum.
(exit_thread): Delete declaration.
Diffstat (limited to 'winsup/cygwin/init.cc')
-rw-r--r-- | winsup/cygwin/init.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index 1b245f581..d6cfb8868 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -13,6 +13,7 @@ details. */ #include "cygtls.h" #include "ntdll.h" #include "shared_info.h" +#include "sync.h" static DWORD _my_oldfunc; @@ -95,7 +96,14 @@ dll_entry (HANDLE h, DWORD reason, void *static_load) if (dll_finished_loading && (PVOID) &_my_tls > (PVOID) &test_stack_marker && _my_tls.isinitialized ()) - _my_tls.remove (0); + { + _my_tls.remove (0); + /* Make sure that we don't exit until the process has exited. + Otherwise there is a potential race where the thread exit + code could be considered to be the process exit code. + See cgf-000017 and cgf-000018 in DevNotes. */ + lock_process here; + } /* Windows 2000 has a bug in NtTerminateThread. Instead of releasing the stack at teb->DeallocationStack it uses the value of teb->Tib.StackLimit to evaluate the stack address. So we just claim |