diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-04-11 08:40:10 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-04-11 20:59:49 +0300 |
commit | 09dd6a62b7ef8cd3d519599ad5e0c67d000fc1fe (patch) | |
tree | 2dd91d35c7bff5038630ae73f22ca3f711c447c1 /pthread_stop_world.c | |
parent | c53e2ed95352a85bc3255883e5e5287c31a4b02a (diff) | |
download | bdwgc-09dd6a62b7ef8cd3d519599ad5e0c67d000fc1fe.tar.gz |
Do not use usleep between signals resend if ThreadSanitizer
Issue #236 (bdwgc).
For a reason, usleep() hangs trying to acquire some TSan lock when
called resend_lost_signals().
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && THREAD_SANITIZER]
(GC_usleep): Use sched_yield() in a loop instead of usleep() or
nanosleep(); update comment.
Diffstat (limited to 'pthread_stop_world.c')
-rw-r--r-- | pthread_stop_world.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 9e146831..281fb352 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -36,8 +36,9 @@ #ifndef GC_OPENBSD_UTHREADS GC_INLINE void GC_usleep(unsigned us) { -# ifdef LINT2 - /* Workaround "waiting while holding a lock" warning. */ +# if defined(LINT2) || defined(THREAD_SANITIZER) + /* Workaround "waiting while holding a lock" static analyzer warning. */ + /* Workaround a rare hang in usleep() trying to acquire TSan Lock. */ while (us-- > 0) sched_yield(); /* pretending it takes 1us */ # elif defined(CPPCHECK) /* || _POSIX_C_SOURCE >= 199309L */ |