Skip to content

[tsan] Test __tsan_test_only_on_fork only on Mac #96597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

vitalybuka
Copy link
Collaborator

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.

Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented Jun 25, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/96597.diff

2 Files Affected:

  • (modified) compiler-rt/lib/tsan/rtl/tsan_rtl.cpp (+4)
  • (renamed) compiler-rt/test/tsan/Darwin/fork_deadlock.cpp ()
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
index fd9441dfcb53c..2d5992b703a6a 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -35,8 +35,10 @@ extern "C" void __tsan_resume() {
   __tsan_resumed = 1;
 }
 
+#if SANITIZER_APPLE
 SANITIZER_WEAK_DEFAULT_IMPL
 void __tsan_test_only_on_fork() {}
+#endif
 
 namespace __tsan {
 
@@ -828,7 +830,9 @@ void ForkBefore(ThreadState* thr, uptr pc) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
   // Disables memory write in OnUserAlloc/Free.
   thr->ignore_reads_and_writes++;
 
+#  if SANITIZER_APPLE
   __tsan_test_only_on_fork();
+#  endif
 }
 
 static void ForkAfter(ThreadState* thr) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
diff --git a/compiler-rt/test/tsan/Linux/fork_deadlock.cpp b/compiler-rt/test/tsan/Darwin/fork_deadlock.cpp
similarity index 100%
rename from compiler-rt/test/tsan/Linux/fork_deadlock.cpp
rename to compiler-rt/test/tsan/Darwin/fork_deadlock.cpp

@vitalybuka vitalybuka changed the base branch from users/vitalybuka/spr/main.tsan-test-__tsan_test_only_on_fork-only-on-mac to main June 25, 2024 16:56
Created using spr 1.3.4
@vitalybuka vitalybuka merged commit 0b049ce into main Jun 25, 2024
4 of 5 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/tsan-test-__tsan_test_only_on_fork-only-on-mac branch June 25, 2024 16:58
@vitalybuka
Copy link
Collaborator Author

I am going to land dependent changes on top of this patch.

If this breaks stuff on some Apple bots, instead of reverting, please just mark the test as UNSUPPORTED, and let me know.

@aeubanks
Copy link
Contributor

aeubanks commented Jun 27, 2024

we're seeing the following on our mac bots:

 /Volumes/Work/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/tsan/Darwin/fork_deadlock.cpp:8:10: fatal error: 'syscall.h' file not found
     8 | #include "syscall.h"
       |          ^~~~~~~~~~~
 1 error generated.

and yeah I don't see a syscall.h in compiler-rt/test/tsan/Darwin/syscall.h, only compiler-rt/test/tsan/Linux/syscall.h

aeubanks added a commit that referenced this pull request Jun 27, 2024
This test is broken since there's no "syscall.h". As requested in #96597, mark test as UNSUPPORTED instead of reverting.
@aeubanks
Copy link
Contributor

test marked UNSUPPORTED in 8044158

lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
This test is broken since there's no "syscall.h". As requested in llvm#96597, mark test as UNSUPPORTED instead of reverting.
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants