Don't run the destructors directly after executing the user thread function. This allows running other TLS callbacks (e.g. tls_atexit.c) before running destructors registered via pthread_key_create (which can be used by the libgcc emutls allocations, if libgcc is built with the pthread thread model).
Signed-off-by: Martin Storsjö <[email protected]> --- mingw-w64-libraries/winpthreads/src/thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mingw-w64-libraries/winpthreads/src/thread.c b/mingw-w64-libraries/winpthreads/src/thread.c index 55361aec9..6803630fb 100644 --- a/mingw-w64-libraries/winpthreads/src/thread.c +++ b/mingw-w64-libraries/winpthreads/src/thread.c @@ -496,6 +496,7 @@ __dyn_tls_pthread (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) if (t->evStart) CloseHandle (t->evStart); t->evStart = NULL; + _pthread_cleanup_dest (t->x); pthread_mutex_destroy (&t->p_clock); replace_spin_keys (&t->spin_keys, new_spin_keys); } @@ -1084,7 +1085,6 @@ pthread_exit (void *res) id->ret_arg = res; - _pthread_cleanup_dest (id->x); if (id->thread_noposix == 0) longjmp(id->jb, 1); @@ -1093,6 +1093,7 @@ pthread_exit (void *res) { if (!t->h) { + _pthread_cleanup_dest (id->x); t->valid = DEAD_THREAD; if (t->evStart) CloseHandle (t->evStart); @@ -1111,6 +1112,7 @@ pthread_exit (void *res) t->evStart = NULL; if ((t->p_state & PTHREAD_CREATE_DETACHED) == PTHREAD_CREATE_DETACHED) { + _pthread_cleanup_dest (id->x); t->valid = DEAD_THREAD; CloseHandle (t->h); t->h = NULL; @@ -1536,8 +1538,6 @@ pthread_create_wrapper (void *args) #endif pthread_mutex_lock (&mtx_pthr_locked); tv->ret_arg = (void*) trslt; - /* Clean up destructors */ - _pthread_cleanup_dest(tv->x); } else pthread_mutex_lock (&mtx_pthr_locked); -- 2.17.1 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
