1 // RUN: %clang_tsan %s -o %t -framework Foundation
2 // RUN: %deflake %run %t 2>&1 | FileCheck %s
4 #import <Foundation/Foundation.h>
11 fprintf(stderr, "Hello world.\n");
12 print_address("addr=", 1, &global);
13 barrier_init(&barrier, 2);
16 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
18 barrier_wait(&barrier);
21 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
22 barrier_wait(&barrier);
25 dispatch_sync(dispatch_get_main_queue(), ^{
26 CFRunLoopStop(CFRunLoopGetCurrent());
31 fprintf(stderr, "Done.\n");
34 // CHECK: Hello world.
35 // CHECK: WARNING: ThreadSanitizer: data race
36 // CHECK: Write of size 8
37 // CHECK: Previous write of size 8
38 // CHECK: Location is global
39 // CHECK: Thread {{.*}} is a GCD worker thread
40 // CHECK-NOT: failed to restore the stack
41 // CHECK: Thread {{.*}} is a GCD worker thread
42 // CHECK-NOT: failed to restore the stack