Skip to content

Commit 5ca93cb

Browse files
vitalybukaAlexisPerry
authored andcommitted
[tsan] Test __tsan_test_only_on_fork only on Mac (llvm#96597)
According to https://reviews.llvm.org/D114250 this was to handle Mac specific issue, however the test is Linux only. The test effectively prevents to lock main allocator on fork, but we do that on Linux for other sanitizers for years, and need to do the same for TSAN to avoid deadlocks.
1 parent b1e00ac commit 5ca93cb

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

compiler-rt/lib/tsan/rtl/tsan_rtl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ extern "C" void __tsan_resume() {
3535
__tsan_resumed = 1;
3636
}
3737

38+
#if SANITIZER_APPLE
3839
SANITIZER_WEAK_DEFAULT_IMPL
3940
void __tsan_test_only_on_fork() {}
41+
#endif
4042

4143
namespace __tsan {
4244

@@ -828,7 +830,9 @@ void ForkBefore(ThreadState* thr, uptr pc) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
828830
// Disables memory write in OnUserAlloc/Free.
829831
thr->ignore_reads_and_writes++;
830832

833+
# if SANITIZER_APPLE
831834
__tsan_test_only_on_fork();
835+
# endif
832836
}
833837

834838
static void ForkAfter(ThreadState* thr) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {

0 commit comments

Comments
 (0)