From: Ivan Maidanski Date: Mon, 27 Feb 2012 17:49:35 +0000 (+0400) Subject: Fix GC_register_my_thread marking thread as detached (Cygwin/pthreads-w32) X-Git-Tag: gc7_3alpha2~76 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a25488c8592e2eddd67625fc2b5a7d8597e400d4;p=gc Fix GC_register_my_thread marking thread as detached (Cygwin/pthreads-w32) * win32_threads.c (GC_register_my_thread): Fix SEGV by setting "me" to the newly-created thread GC descriptor (if lookup failed) before altering flags of "me" (only if GC_PTHREADS); add comment (same as in pthread_support.c). --- diff --git a/win32_threads.c b/win32_threads.c index c3e80323..652191d9 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -738,9 +738,13 @@ GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *sb) LOCK(); me = GC_lookup_thread_inner(thread_id); if (me == 0) { - GC_register_my_thread_inner(sb, thread_id); # ifdef GC_PTHREADS + me = GC_register_my_thread_inner(sb, thread_id); me -> flags |= DETACHED; + /* Treat as detached, since we do not need to worry about */ + /* pointer results. */ +# else + GC_register_my_thread_inner(sb, thread_id); # endif UNLOCK(); return GC_SUCCESS;