aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/compiler-rt/lib/lsan/lsan_posix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/compiler-rt/lib/lsan/lsan_posix.cpp')
-rw-r--r--contrib/llvm-project/compiler-rt/lib/lsan/lsan_posix.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/contrib/llvm-project/compiler-rt/lib/lsan/lsan_posix.cpp b/contrib/llvm-project/compiler-rt/lib/lsan/lsan_posix.cpp
index 3677f0141a2f..422c29acca69 100644
--- a/contrib/llvm-project/compiler-rt/lib/lsan/lsan_posix.cpp
+++ b/contrib/llvm-project/compiler-rt/lib/lsan/lsan_posix.cpp
@@ -100,20 +100,27 @@ void InstallAtExitCheckLeaks() {
Atexit(DoLeakCheck);
}
+static void BeforeFork() {
+ LockGlobal();
+ LockThreads();
+ LockAllocator();
+ StackDepotLockBeforeFork();
+}
+
+static void AfterFork(bool fork_child) {
+ StackDepotUnlockAfterFork(fork_child);
+ UnlockAllocator();
+ UnlockThreads();
+ UnlockGlobal();
+}
+
void InstallAtForkHandler() {
- auto before = []() {
- LockGlobal();
- LockThreads();
- LockAllocator();
- StackDepotLockAll();
- };
- auto after = []() {
- StackDepotUnlockAll();
- UnlockAllocator();
- UnlockThreads();
- UnlockGlobal();
- };
- pthread_atfork(before, after, after);
+# if SANITIZER_SOLARIS || SANITIZER_NETBSD || SANITIZER_APPLE
+ return; // FIXME: Implement FutexWait.
+# endif
+ pthread_atfork(
+ &BeforeFork, []() { AfterFork(/* fork_child= */ false); },
+ []() { AfterFork(/* fork_child= */ true); });
}
} // namespace __lsan