Skip to content

Commit

Permalink
[sanitizer_common] Block asynchronous signals only (#98200)
Browse files Browse the repository at this point in the history
This changes the behavior of `BlockSignals` and `ScopedBlockSignals` to
block only asynchronous signals.

This extension is intended to be used in a future fix for MSan (block
async signals during `MsanThread::Destroy`).
  • Loading branch information
thurstond authored Jul 10, 2024
1 parent 34c544e commit ed8565c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void SetSigProcMask(__sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset) {
CHECK_EQ(0, internal_sigprocmask(SIG_SETMASK, set, oldset));
}

// Block asynchronous signals
void BlockSignals(__sanitizer_sigset_t *oldset) {
__sanitizer_sigset_t set;
internal_sigfillset(&set);
Expand All @@ -170,6 +171,16 @@ void BlockSignals(__sanitizer_sigset_t *oldset) {
// hang.
internal_sigdelset(&set, 31);
# endif

// Don't block synchronous signals
internal_sigdelset(&set, SIGSEGV);
internal_sigdelset(&set, SIGBUS);
internal_sigdelset(&set, SIGILL);
internal_sigdelset(&set, SIGTRAP);
internal_sigdelset(&set, SIGABRT);
internal_sigdelset(&set, SIGFPE);
internal_sigdelset(&set, SIGPIPE);

SetSigProcMask(&set, oldset);
}

Expand Down

0 comments on commit ed8565c

Please sign in to comment.