diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp --- a/compiler-rt/lib/asan/asan_interceptors.cpp +++ b/compiler-rt/lib/asan/asan_interceptors.cpp @@ -223,6 +223,11 @@ auto self = GetThreadSelf(); auto args = asanThreadArgRetval().GetArgs(self); t->ThreadStart(GetTid()); + + __sanitizer_sigset_t sigset; + t->GetStartData(sigset); + SetSigProcMask(&sigset, nullptr); + thread_return_t retval = (*args.routine)(args.arg_retval); asanThreadArgRetval().Finish(self, retval); return retval; @@ -242,7 +247,11 @@ }(); u32 current_tid = GetCurrentTidOrInvalid(); - AsanThread *t = AsanThread::Create(current_tid, &stack, detached); + + __sanitizer_sigset_t sigset; + ScopedBlockSignals block(&sigset); + + AsanThread *t = AsanThread::Create(sigset, current_tid, &stack, detached); int result; { diff --git a/compiler-rt/lib/asan/asan_posix.cpp b/compiler-rt/lib/asan/asan_posix.cpp --- a/compiler-rt/lib/asan/asan_posix.cpp +++ b/compiler-rt/lib/asan/asan_posix.cpp @@ -138,6 +138,11 @@ CHECK_EQ(0, pthread_setspecific(tsd_key, tsd)); return; } +# if SANITIZER_LINUX + // After this point it's unsafe to execute signal handlers which may be + // instrumented. It's probably not just a Linux issue. + BlockSignals(); +# endif AsanThread::TSDDtor(tsd); } #endif