diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-04-04 21:05:51 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-04-04 21:05:51 +0300 |
commit | 9bf0bb0b5c95cd0b99cae18826841b64fc758710 (patch) | |
tree | 7d63d3b64428572f6b0d5f5eb7f8653930e902b1 /pthread_stop_world.c | |
parent | 851cf18b802ba8286bd48cb5c288075a75eba4bd (diff) | |
download | bdwgc-9bf0bb0b5c95cd0b99cae18826841b64fc758710.tar.gz |
Avoid potential signal loss before sigsuspend in suspend_handler if TSan
Issue #236 (bdwgc).
As comment between sem_post() and sigsuspend() says GC_sig_thr_restart
signal should be masked at that point otherwise there could be a race.
Thus, this commit removes pthread_sigmask(SIG_UNBLOCK) call before
sem_post() one in GC_suspend_handler_inner.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_suspend_handler_inner): Remove "set" local
variable; do not call sigemptyset(), pthread_sigmask(SIG_UNBLOCK),
sigaddset().
Diffstat (limited to 'pthread_stop_world.c')
-rw-r--r-- | pthread_stop_world.c | 14 |
1 files changed, 0 insertions, 14 deletions
diff --git a/pthread_stop_world.c b/pthread_stop_world.c index ae5bc77b..33470e62 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -392,20 +392,6 @@ STATIC void GC_suspend_handler_inner(ptr_t dummy GC_ATTR_UNUSED, me -> backing_store_ptr = bs_lo + stack_size; # endif -# ifdef THREAD_SANITIZER - /* TSan disables signals around signal handlers. Without */ - /* a pthread_sigmask call, sigsuspend may block forever. */ - { - sigset_t set; - sigemptyset(&set); - GC_ASSERT(GC_sig_suspend != SIGNAL_UNSET); - GC_ASSERT(GC_sig_thr_restart != SIGNAL_UNSET); - sigaddset(&set, GC_sig_suspend); - sigaddset(&set, GC_sig_thr_restart); - if (pthread_sigmask(SIG_UNBLOCK, &set, NULL) != 0) - ABORT("pthread_sigmask failed in suspend handler"); - } -# endif /* Tell the thread that wants to stop the world that this */ /* thread has been stopped. Note that sem_post() is */ /* the only async-signal-safe primitive in LinuxThreads. */ |