aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/Darwin/dispatch_main.mm
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:45:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:45:36 +0000
commit6f08730ec5f639f05f2f15354171e4a3c9af9dc1 (patch)
tree7374e9d4448083010ada98d17976199c7e945d47 /test/tsan/Darwin/dispatch_main.mm
parentc003a57e2e4a1ad9be0338806bc1038b6987155f (diff)
downloadsrc-6f08730ec5f639f05f2f15354171e4a3c9af9dc1.tar.gz
src-6f08730ec5f639f05f2f15354171e4a3c9af9dc1.zip
Vendor import of compiler-rt release_39 branch r276489:vendor/compiler-rt/compiler-rt-release_39-r276489
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=303235 svn path=/vendor/compiler-rt/compiler-rt-release_39-r276489/; revision=303236; tag=vendor/compiler-rt/compiler-rt-release_39-r276489
Diffstat (limited to 'test/tsan/Darwin/dispatch_main.mm')
-rw-r--r--test/tsan/Darwin/dispatch_main.mm38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/tsan/Darwin/dispatch_main.mm b/test/tsan/Darwin/dispatch_main.mm
new file mode 100644
index 000000000000..75887547c606
--- /dev/null
+++ b/test/tsan/Darwin/dispatch_main.mm
@@ -0,0 +1,38 @@
+// Check that we don't crash when dispatch_main calls pthread_exit which
+// quits the main thread.
+
+// RUN: %clang_tsan %s -o %t -framework Foundation
+// RUN: %env_tsan_opts=ignore_interceptors_accesses=1 %run %t 2>&1 | FileCheck %s
+
+#import <Foundation/Foundation.h>
+
+int main() {
+ fprintf(stderr,"Hello world");
+
+ dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
+
+ dispatch_async(q, ^{
+ fprintf(stderr,"1");
+ });
+
+ dispatch_async(q, ^{
+ fprintf(stderr,"2");
+ });
+
+ dispatch_async(q, ^{
+ fprintf(stderr,"3");
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+ fprintf(stderr,"Done.");
+ sleep(1);
+ exit(0);
+ });
+ });
+
+ dispatch_main();
+}
+
+// CHECK: Hello world
+// CHECK: Done.
+// CHECK-NOT: WARNING: ThreadSanitizer
+// CHECK-NOT: CHECK failed