From: Ivan Maidanski Date: Fri, 23 Mar 2018 08:13:23 +0000 (+0300) Subject: Fix thread_suspend fail for threads registered from key destructor (OS X) X-Git-Tag: v8.0.0~276 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=877e5ea565b7afd1890f33c89c3cff148ccd32a6;p=gc Fix thread_suspend fail for threads registered from key destructor (OS X) 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. --- diff --git a/pthread_support.c b/pthread_support.c index 5a9b8284..339d631d 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -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