]> granicus.if.org Git - gc/commitdiff
Fix thread_suspend fail for threads registered from key destructor (OS X)
authorIvan Maidanski <ivmai@mail.ru>
Fri, 23 Mar 2018 08:13:23 +0000 (11:13 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 23 Mar 2018 08:13:23 +0000 (11:13 +0300)
Issue #213 (bdwgc).

* pthread_support.c [GC_DARWIN_THREADS] (GC_register_my_thread):
Reinitialize stop_info.mach_thread if the thread is registered from
the client thread key destructor; add comment.

pthread_support.c

index 5a9b8284229fa325b2e166a440f9bd9dc33956e9..339d631d2447e841bacfe0ea1cd6248d8172ffba 100644 (file)
@@ -1719,6 +1719,11 @@ GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *sb)
     } else if ((me -> flags & FINISHED) != 0) {
         /* This code is executed when a thread is registered from the   */
         /* client thread key destructor.                                */
+#       ifdef GC_DARWIN_THREADS
+          /* Reinitialize mach_thread to avoid thread_suspend fail      */
+          /* with MACH_SEND_INVALID_DEST error.                         */
+          me -> stop_info.mach_thread = mach_thread_self();
+#       endif
         GC_record_stack_base(me, sb);
         me -> flags &= ~FINISHED; /* but not DETACHED */
 #       ifdef GC_EXPLICIT_SIGNALS_UNBLOCK