From a98c23626538ce101d8903fdc5079c0a4efc2f7e Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 21 Jun 2016 12:12:56 +0300 Subject: [PATCH] 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. --- pthread_stop_world.c | 4 ++++ 1 file changed, 4 insertions(+) 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(); } -- 2.40.0