This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Use pthread_sigmask instead of sigprocmask to block signals in a thread on Darwin
ClosedPublic

Authored by kubamracek on Jul 5 2017, 9:27 AM.

Details

Summary

On Darwin, sigprocmask changes the signal mask for the entire process. This has some unwanted consequences, because e.g. internal_start_thread wants to disable signals only in the current thread (to make the new thread inherit the signal mask), which is currently broken on Darwin. This patch switches to pthread_sigmask.

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek created this revision.Jul 5 2017, 9:27 AM
dvyukov added inline comments.Jul 5 2017, 10:36 AM
lib/sanitizer_common/sanitizer_mac.cc
511 ↗(On Diff #105281)

I think you either need to (1) change implementation of internal_sigprocmask to follow the unofficial contract of affecting only the current thread, or (2) delete internal_sigprocmask.

(1) looks preferable to me as it will allow to write portable code for "unix" OSes, and make the code more consistent as we use __sanitizer_sigset_t and internal_sigfillset in this function, and move us closer to the ultimate goal of not using any library functions that loop into interceptors in favor of system calls (even if you use pthread_sigmask on implementation level for now).

dvyukov accepted this revision.Jul 5 2017, 11:04 AM
This revision is now accepted and ready to land.Jul 5 2017, 11:04 AM
This revision was automatically updated to reflect the committed changes.