[compiler-rt] fff8b32 - [msan] Block signals during MsanThread::TSDDtor (#98405)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 08:26:09 PDT 2024


Author: Thurston Dang
Date: 2024-07-11T08:26:04-07:00
New Revision: fff8b3236ab8ce8f99ea83a4de7c0e88687fc09d

URL: https://github.com/llvm/llvm-project/commit/fff8b3236ab8ce8f99ea83a4de7c0e88687fc09d
DIFF: https://github.com/llvm/llvm-project/commit/fff8b3236ab8ce8f99ea83a4de7c0e88687fc09d.diff

LOG: [msan] Block signals during MsanThread::TSDDtor (#98405)

MSan may segfault inside a signal handler, if MSan instrumentation is
trying to access thread-local storage that has already been destroyed.
This fixes the issue by blocking asychronous signals inside
MsanThread::TSDDtor. This is based on an idea suggested by Paul
Pluzhnikov (block async signals in MsanThread::Destroy()) and refined by
Vitaly Buka.
    
Note: ed8565cf0b64ea5e88cc94f321b1870bb105d09d changed *BlockSignals to
only block asynchronous signals, despite the name.

Added: 
    

Modified: 
    compiler-rt/lib/msan/msan_linux.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/msan/msan_linux.cpp b/compiler-rt/lib/msan/msan_linux.cpp
index c68aec60ae13e..708a06d59a347 100644
--- a/compiler-rt/lib/msan/msan_linux.cpp
+++ b/compiler-rt/lib/msan/msan_linux.cpp
@@ -292,6 +292,7 @@ void MsanTSDDtor(void *tsd) {
     CHECK_EQ(0, pthread_setspecific(tsd_key, tsd));
     return;
   }
+  ScopedBlockSignals block(nullptr);
   msan_current_thread = nullptr;
   // Make sure that signal handler can not see a stale current thread pointer.
   atomic_signal_fence(memory_order_seq_cst);


        


More information about the llvm-commits mailing list