Skip to content

Commit

Permalink
Workaround a hang in sigsuspend if compiled with Thread Sanitizer
Browse files Browse the repository at this point in the history
Issue #181 (bdwgc).

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_suspend_handler_inner): Use sched_yield()
instead of sigsuspend(&suspend_handler_mask); add TODO item.
  • Loading branch information
ivmai committed Nov 13, 2017
1 parent 918500d commit 04fd7b5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pthread_stop_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,16 @@ STATIC void GC_suspend_handler_inner(ptr_t dummy GC_ATTR_UNUSED,
/* really safe to proceed. Under normal circumstances, */
/* this code should not be executed. */
do {
# ifdef THREAD_SANITIZER
/* TODO: A temporal workaround. Generally, signal handlers are */
/* delayed until the next call to TSan ProcessPendingSignals, the */
/* latter is called on interceptors, system calls, and atomic */
/* operations only. Thus, the collector hangs sometimes (as of */
/* now) if the signal occurs while waiting in sigsuspend(). */
sched_yield();
# else
sigsuspend (&suspend_handler_mask);
# endif
} while (AO_load_acquire(&GC_world_is_stopped)
&& AO_load(&GC_stop_count) == my_stop_count);
/* If the RESTART signal gets lost, we can still lose. That should */
Expand Down

0 comments on commit 04fd7b5

Please sign in to comment.