Skip to content

Commit

Permalink
Do not use usleep between signals resend if ThreadSanitizer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ivmai committed Apr 11, 2022
1 parent c53e2ed commit 09dd6a6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pthread_stop_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 09dd6a6

Please sign in to comment.