Skip to content

Commit fff8b32

Browse files
authored
[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: ed8565c changed *BlockSignals to only block asynchronous signals, despite the name.
1 parent bbb90fe commit fff8b32

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

compiler-rt/lib/msan/msan_linux.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ void MsanTSDDtor(void *tsd) {
292292
CHECK_EQ(0, pthread_setspecific(tsd_key, tsd));
293293
return;
294294
}
295+
ScopedBlockSignals block(nullptr);
295296
msan_current_thread = nullptr;
296297
// Make sure that signal handler can not see a stale current thread pointer.
297298
atomic_signal_fence(memory_order_seq_cst);

0 commit comments

Comments
 (0)