]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/compiler-rt/test/tsan/Darwin/dispatch_main.mm
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / tsan / Darwin / dispatch_main.mm
CommitLineData
5bcae85e
SL
1// Check that we don't crash when dispatch_main calls pthread_exit which
2// quits the main thread.
3
4// RUN: %clang_tsan %s -o %t -framework Foundation
2c00a5a8 5// RUN: %run %t 2>&1 | FileCheck %s
5bcae85e
SL
6
7#import <Foundation/Foundation.h>
8
9int main() {
10 fprintf(stderr,"Hello world");
11
12 dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
13
14 dispatch_async(q, ^{
15 fprintf(stderr,"1");
16 });
17
18 dispatch_async(q, ^{
19 fprintf(stderr,"2");
20 });
21
22 dispatch_async(q, ^{
23 fprintf(stderr,"3");
24
25 dispatch_async(dispatch_get_main_queue(), ^{
26 fprintf(stderr,"Done.");
27 sleep(1);
28 exit(0);
29 });
30 });
31
32 dispatch_main();
33}
34
35// CHECK: Hello world
36// CHECK: Done.
37// CHECK-NOT: WARNING: ThreadSanitizer
38// CHECK-NOT: CHECK failed