Fix GC_register_my_thread marking thread as detached (Cygwin/pthreads-w32)
authorIvan Maidanski <ivmai@mail.ru>
Mon, 27 Feb 2012 17:49:35 +0000 (21:49 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 27 Feb 2012 17:49:35 +0000 (21:49 +0400)
* 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).

win32_threads.c

index c3e8032..652191d 100644 (file)
@@ -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;