From: Ivan Maidanski Date: Wed, 27 Sep 2017 07:52:09 +0000 (+0300) Subject: Fix pthread_detach for threads not yet registered (Cygwin, winpthreads) X-Git-Tag: v8.0.0~569 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c36a51c9112c36c6ccf2d4d43e41ddb093d183a;p=gc Fix pthread_detach for threads not yet registered (Cygwin, winpthreads) * win32_threads.c [GC_PTHREADS] (GC_pthread_detach): Repeat GC_lookup_pthread() (with a 10 msec delay) while t is null; add comment and TODO; remove ABORT if t is null (as t is never null after pthread_detach call). --- diff --git a/win32_threads.c b/win32_threads.c index e89c0b1a..dd2df381 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -2720,10 +2720,12 @@ GC_INNER void GC_thr_init(void) DCL_LOCK_STATE; GC_ASSERT(!GC_win32_dll_threads); - t = GC_lookup_pthread(thread); + /* The thread might not have registered itself yet. */ + /* TODO: Wait for registration of the created thread in pthread_create. */ + while ((t = GC_lookup_pthread(thread)) == NULL) + Sleep(10); result = pthread_detach(thread); if (result == 0) { - if (NULL == t) ABORT("Thread not registered"); LOCK(); t -> flags |= DETACHED; /* Here the pthread thread id may have been recycled. */