[compiler-rt] f2c2292 - [msan] Block signals in MsanThread::Init
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 9 18:24:08 PST 2021
Author: Vitaly Buka
Date: 2021-11-09T18:23:55-08:00
New Revision: f2c2292fa801896751cadec4f65bef88bf83ba5b
URL: https://github.com/llvm/llvm-project/commit/f2c2292fa801896751cadec4f65bef88bf83ba5b
DIFF: https://github.com/llvm/llvm-project/commit/f2c2292fa801896751cadec4f65bef88bf83ba5b.diff
LOG: [msan] Block signals in MsanThread::Init
If async signal handler called when we MsanThread::Init
signal handler may trigger false reports.
I failed to reproduce this locally for a test.
Differential Revision: https://reviews.llvm.org/D113328
Added:
Modified:
compiler-rt/lib/msan/msan_interceptors.cpp
compiler-rt/lib/msan/msan_thread.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/msan/msan_interceptors.cpp b/compiler-rt/lib/msan/msan_interceptors.cpp
index 46bdfa0e84d5a..a79221f3db9dd 100644
--- a/compiler-rt/lib/msan/msan_interceptors.cpp
+++ b/compiler-rt/lib/msan/msan_interceptors.cpp
@@ -1034,6 +1034,7 @@ static void *MsanThreadStartFunc(void *arg) {
MsanThread *t = (MsanThread *)arg;
SetCurrentThread(t);
t->Init();
+ SetSigProcMask(&t->starting_sigset_, nullptr);
return t->ThreadStart();
}
@@ -1049,7 +1050,7 @@ INTERCEPTOR(int, pthread_create, void *th, void *attr, void *(*callback)(void*),
AdjustStackSize(attr);
MsanThread *t = MsanThread::Create(callback, param);
-
+ ScopedBlockSignals block(&t->starting_sigset_);
int res = REAL(pthread_create)(th, attr, MsanThreadStartFunc, t);
if (attr == &myattr)
diff --git a/compiler-rt/lib/msan/msan_thread.h b/compiler-rt/lib/msan/msan_thread.h
index fe795e3a547ad..f6ed1534cccdf 100644
--- a/compiler-rt/lib/msan/msan_thread.h
+++ b/compiler-rt/lib/msan/msan_thread.h
@@ -15,7 +15,7 @@
#include "msan_allocator.h"
#include "sanitizer_common/sanitizer_common.h"
-
+#include "sanitizer_common/sanitizer_posix.h"
namespace __msan {
class MsanThread {
@@ -45,6 +45,7 @@ class MsanThread {
MsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; }
int destructor_iterations_;
+ __sanitizer_sigset_t starting_sigset_;
private:
// NOTE: There is no MsanThread constructor. It is allocated
More information about the llvm-commits
mailing list