[compiler-rt] r298707 - Update debug_external.cc testcase to use TSan-invisible barriers to reduce flakiness.

Kuba Mracek via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 09:37:03 PDT 2017


Author: kuba.brecka
Date: Fri Mar 24 11:37:02 2017
New Revision: 298707

URL: http://llvm.org/viewvc/llvm-project?rev=298707&view=rev
Log:
Update debug_external.cc testcase to use TSan-invisible barriers to reduce flakiness.


Modified:
    compiler-rt/trunk/test/tsan/Darwin/debug_external.cc

Modified: compiler-rt/trunk/test/tsan/Darwin/debug_external.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/Darwin/debug_external.cc?rev=298707&r1=298706&r2=298707&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/Darwin/debug_external.cc (original)
+++ compiler-rt/trunk/test/tsan/Darwin/debug_external.cc Fri Mar 24 11:37:02 2017
@@ -6,6 +6,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../test.h"
+
 extern "C" {
 void __tsan_on_report(void *report);
 int __tsan_get_report_loc(void *report, unsigned long idx, const char **type,
@@ -20,11 +22,13 @@ void __tsan_external_assign_tag(void *ad
 }
 
 void *Thread(void *arg) {
+  barrier_wait(&barrier);
   *((long *)arg) = 42;
   return NULL;
 }
 
 int main() {
+  barrier_init(&barrier, 2);
   void *tag = __tsan_external_register_tag("MyObject");
   long *obj = (long *)malloc(sizeof(long));
   fprintf(stderr, "obj = %p\n", obj);
@@ -34,6 +38,7 @@ int main() {
   pthread_t t;
   pthread_create(&t, 0, Thread, obj);
   *obj = 41;
+  barrier_wait(&barrier);
   pthread_join(t, 0);
   fprintf(stderr, "Done.\n");
   return 0;




More information about the llvm-commits mailing list