[compiler-rt] be77afe - tsan: Add a missing disable_sanitizer_instrumentation attribute
Alexander Potapenko via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 17 06:34:48 PST 2022
Author: Alexander Potapenko
Date: 2022-02-17T15:34:41+01:00
New Revision: be77afe43dd39f517ab2468c359fd0d5633d9be6
URL: https://github.com/llvm/llvm-project/commit/be77afe43dd39f517ab2468c359fd0d5633d9be6
DIFF: https://github.com/llvm/llvm-project/commit/be77afe43dd39f517ab2468c359fd0d5633d9be6.diff
LOG: tsan: Add a missing disable_sanitizer_instrumentation attribute
Turns out the test was working by accident: we need to ensure
TSan instrumentation is not called from the fork() hook, otherwise the
tool will deadlock. Previously it worked because alloc_free_blocks() got
inlined into __tsan_test_only_on_fork(), but it cannot always be the
case.
Adding __attribute__((disable_sanitizer_instrumentation)) will prevent
TSan from instrumenting alloc_free_blocks().
Reviewed By: dvyukov
Differential Revision: https://reviews.llvm.org/D120050
Added:
Modified:
compiler-rt/test/tsan/Linux/fork_deadlock.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/tsan/Linux/fork_deadlock.cpp b/compiler-rt/test/tsan/Linux/fork_deadlock.cpp
index 8f38ab92e69f6..952507032df65 100644
--- a/compiler-rt/test/tsan/Linux/fork_deadlock.cpp
+++ b/compiler-rt/test/tsan/Linux/fork_deadlock.cpp
@@ -11,7 +11,10 @@
#include <sys/types.h>
#include <sys/wait.h>
-void alloc_free_blocks() {
+// disable_sanitizer_instrumentation on __tsan_test_only_on_fork is not
+// transitive, so we must apply it here as well.
+// Instrumenting alloc_free_blocks() will result in deadlocks in TSan.
+__attribute__((disable_sanitizer_instrumentation)) void alloc_free_blocks() {
// Allocate a bunch of blocks to drain local allocator cache
// and provoke it to lock allocator global mutexes.
const int kBlocks = 1000;
More information about the llvm-commits
mailing list