From: Ivan Maidanski Date: Tue, 21 Jun 2016 09:12:56 +0000 (+0300) Subject: Fix GC_suspend_thread regarding potential cancellation of sem_wait X-Git-Tag: gc7_6_0~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a98c23626538ce101d8903fdc5079c0a4efc2f7e;p=gc Fix GC_suspend_thread regarding potential cancellation of sem_wait * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Call DISABLE_CANCEL before sem_wait, call RESTORE_CANCEL after it. --- diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 1ee9ee8f..dad1fdc9 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -412,6 +412,7 @@ STATIC void GC_restart_handler(int sig) GC_API void GC_CALL GC_suspend_thread(GC_SUSPEND_THREAD_ID thread) { GC_thread t; + IF_CANCEL(int cancel_state;) DCL_LOCK_STATE; LOCK(); @@ -447,10 +448,13 @@ STATIC void GC_restart_handler(int sig) /* Wait for the thread to complete threads table lookup and */ /* stack_ptr assignment. */ GC_ASSERT(GC_thr_initialized); + DISABLE_CANCEL(cancel_state); + /* GC_suspend_thread is not a cancellation point. */ while (sem_wait(&GC_suspend_ack_sem) != 0) { if (errno != EINTR) ABORT("sem_wait for handler failed (suspend_self)"); } + RESTORE_CANCEL(cancel_state); UNLOCK(); }