From a646d031e70e5f30cf15153299914afb03992159 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 10 Apr 2022 13:26:34 +0300 Subject: Do not send signal to thread which is suspended manually If thread is in do-blocking state (i.e. thread_blocked is set), then suspend it only when it exits from the state. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): If thread_blocked then set thread_blocked, then UNLOCK and return; update comment; check FINISHED flag before checking t is self thread. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_do_blocking_inner, GC_call_with_gc_active): Call GC_suspend_self_inner() not holding GC lock while suspended_ext (before setting thread_blocked to false). --- pthread_stop_world.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'pthread_stop_world.c') diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 7713da9d..65dd2319 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -647,6 +647,12 @@ STATIC void GC_restart_handler(int sig) UNLOCK(); return; } + if ((t -> flags & FINISHED) != 0 || t -> thread_blocked) { + t -> suspended_ext = TRUE; + /* Terminated but not joined yet, or in do-blocking state. */ + UNLOCK(); + return; + } if (THREAD_EQUAL((pthread_t)thread, pthread_self())) { t -> suspended_ext = TRUE; @@ -656,12 +662,6 @@ STATIC void GC_restart_handler(int sig) (void)GC_do_blocking(GC_suspend_self_inner, t); return; } - if ((t -> flags & FINISHED) != 0) { - t -> suspended_ext = TRUE; - /* Terminated but not joined yet. */ - UNLOCK(); - return; - } DISABLE_CANCEL(cancel_state); /* GC_suspend_thread is not a cancellation point. */ -- cgit v1.2.1