From d8789fdf0bc4e542e533859c3bf7568191e5d262 Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Fri, 24 Mar 2017 16:37:02 +0000 Subject: [PATCH] Update debug_external.cc testcase to use TSan-invisible barriers to reduce flakiness. llvm-svn: 298707 --- compiler-rt/test/tsan/Darwin/debug_external.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler-rt/test/tsan/Darwin/debug_external.cc b/compiler-rt/test/tsan/Darwin/debug_external.cc index ac05a01..217690f 100644 --- a/compiler-rt/test/tsan/Darwin/debug_external.cc +++ b/compiler-rt/test/tsan/Darwin/debug_external.cc @@ -6,6 +6,8 @@ #include #include +#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 *addr, void *tag); } 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; -- 2.7.4