blob: e707b6551000723a0bf3ff4b14aefa5a6567cda7 [file] [log] [blame]
Kuba Breckacecb7fa2016-04-07 11:38:53 +00001// RUN: %clang_tsan %s -o %t -framework Foundation
Kuba Mraceke4c1dd22017-01-24 21:37:50 +00002// RUN: %run %t 2>&1 | FileCheck %s
Kuba Breckacecb7fa2016-04-07 11:38:53 +00003
4#import <Foundation/Foundation.h>
5
6long global;
7
8int main(int argc, const char *argv[]) {
9 dispatch_queue_t queue =
10 dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
11
12 dispatch_source_t source =
13 dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
14
15 dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
16
17 global = 42;
18
19 dispatch_source_set_event_handler(source, ^{
20 fprintf(stderr, "global = %ld\n", global);
21
22 dispatch_sync(dispatch_get_main_queue(), ^{
23 CFRunLoopStop(CFRunLoopGetCurrent());
24 });
25 });
26
27 dispatch_resume(source);
28
29 CFRunLoopRun();
30
31 return 0;
32}
33
34// CHECK: global = 42
35// CHECK-NOT: WARNING: ThreadSanitizer