[compiler-rt] f4ab0f6 - [TSan] Avoid deadlock in test for compiler-rt debug build

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 10 11:40:58 PST 2022


Author: Julian Lettner
Date: 2022-01-10T11:40:54-08:00
New Revision: f4ab0f6e097f26e4d05716654d7d60588a61864d

URL: https://github.com/llvm/llvm-project/commit/f4ab0f6e097f26e4d05716654d7d60588a61864d
DIFF: https://github.com/llvm/llvm-project/commit/f4ab0f6e097f26e4d05716654d7d60588a61864d.diff

LOG: [TSan] Avoid deadlock in test for compiler-rt debug build

rdar://86776155

Added: 
    

Modified: 
    compiler-rt/test/tsan/libdispatch/dispatch_once_deadlock.c

Removed: 
    


################################################################################
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 <pthread.h>
 #include <stdio.h>
 
+#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() {


        


More information about the llvm-commits mailing list