• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_tsan %s -o %t -framework Foundation
2// RUN: %env_tsan_opts=ignore_interceptors_accesses=1 %run %t 2>&1 | FileCheck %s
3
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_SIGNAL, SIGHUP, 0, queue);
14
15  global = 42;
16
17  dispatch_source_set_registration_handler(source, ^{
18    fprintf(stderr, "global = %ld\n", global);
19
20    dispatch_sync(dispatch_get_main_queue(), ^{
21      CFRunLoopStop(CFRunLoopGetCurrent());
22    });
23  });
24
25  dispatch_resume(source);
26
27  CFRunLoopRun();
28
29  return 0;
30}
31
32// CHECK: global = 42
33// CHECK-NOT: WARNING: ThreadSanitizer
34