diff --git a/compiler-rt/test/tsan/libdispatch/dispatch_once_deadlock.c b/compiler-rt/test/tsan/libdispatch/dispatch_once_deadlock.c index 8139605c753cc..4e8785baf0745 100644 --- a/compiler-rt/test/tsan/libdispatch/dispatch_once_deadlock.c +++ b/compiler-rt/test/tsan/libdispatch/dispatch_once_deadlock.c @@ -1,4 +1,4 @@ -// Check that calling dispatch_once from a report callback works. +// Check that dispatch_once() is always intercepted. // RUN: %clang_tsan %s -o %t // RUN: not %env_tsan_opts=ignore_noninstrumented_modules=0 %run %t 2>&1 | FileCheck %s @@ -8,6 +8,8 @@ #include #include +#include "../test.h" + long g = 0; long h = 0; @@ -23,7 +25,14 @@ void f() { __attribute__((disable_sanitizer_instrumentation)) void __tsan_on_report() { fprintf(stderr, "Report.\n"); + + // Without these annotations this test deadlocks for COMPILER_RT_DEBUG=ON + // builds. Conceptually, the TSan runtime does not support reentrancy from + // runtime callbacks, but the main goal here is just to check that + // dispatch_once() is always intercepted. + AnnotateIgnoreSyncBegin(__FILE__, __LINE__); f(); + AnnotateIgnoreSyncEnd(__FILE__, __LINE__); } int main() {