1// RUN: %clang_tsan %s -o %t -framework Foundation 2// RUN: %env_tsan_opts=ignore_interceptors_accesses=1 %deflake %run %t 2>&1 | FileCheck %s 3 4#import <Foundation/Foundation.h> 5 6#import "../test.h" 7 8long global; 9 10int main(int argc, const char *argv[]) { 11 barrier_init(&barrier, 2); 12 fprintf(stderr, "start\n"); 13 dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT); 14 dispatch_apply(2, q, ^(size_t i) { 15 global = i; 16 barrier_wait(&barrier); 17 }); 18 19 fprintf(stderr, "done\n"); 20 return 0; 21} 22 23// CHECK: start 24// CHECK: WARNING: ThreadSanitizer: data race 25// CHECK: Location is global 'global' 26// CHECK: done 27