Skip to content

Commit

Permalink
i#2270: Remove alarm handlers before synching with threads.
Browse files Browse the repository at this point in the history
If an alarm is received by a thread after it has blocked in
check_wait_at_safe_spot but before the detaching thread sends the
SUSPEND_SIGNAL, it is possible the fcache_unit_areas lock is being held in
record_pending_signal when the SUSPEND_SIGNAL is received. Since the
receiving signal was alerady marked as waiting at a safe spot, we
synchronize with the thread and detach it, and the fcache_unit_areas
lock is never unlocked.

Issue #2270
  • Loading branch information
Carrotman42 committed Nov 5, 2018
1 parent ac4ab72 commit fabcbcb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/synch.c
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,11 @@ detach_on_permanent_stack(bool internal, bool do_cleanup, dr_stats_t *drstats)
# endif
#endif

#ifdef UNIX
/* i#2270: we ignore alarm signals during detach to reduce races. */
signal_remove_alarm_handlers(my_dcontext);
#endif

/* suspend all DR-controlled threads at safe locations */
if (!synch_with_all_threads(THREAD_SYNCH_SUSPENDED_VALID_MCONTEXT, &threads,
&num_threads,
Expand Down Expand Up @@ -2119,9 +2124,6 @@ detach_on_permanent_stack(bool internal, bool do_cleanup, dr_stats_t *drstats)
/* Release the APC init lock and let any threads waiting there go native */
LOG(GLOBAL, LOG_ALL, 1, "Detach : Releasing init_apc_go_native_pause\n");
init_apc_go_native_pause = false;
#else
/* i#2270: we ignore alarm signals during detach to reduce races. */
signal_remove_alarm_handlers(my_dcontext);
#endif

/* perform exit tasks that require full thread data structs */
Expand Down

0 comments on commit fabcbcb

Please sign in to comment.