1 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t 2>&1 | FileCheck %s
2 // UNSUPPORTED: tvos, watchos
3 // XFAIL: ios && !iossim
4 #include "sanitizer_common/sanitizer_ucontext.h"
7 char stack
[64 * 1024] __attribute__((aligned(16)));
9 ucontext_t uc
, orig_uc
;
10 void *fiber
, *orig_fiber
;
16 __tsan_switch_to_fiber(orig_fiber
, __tsan_switch_to_fiber_no_sync
);
17 swapcontext(&uc
, &orig_uc
);
21 orig_fiber
= __tsan_get_current_fiber();
22 fiber
= __tsan_create_fiber(0);
24 uc
.uc_stack
.ss_sp
= stack
;
25 uc
.uc_stack
.ss_size
= sizeof(stack
);
27 makecontext(&uc
, func
, 0);
29 __tsan_switch_to_fiber(fiber
, __tsan_switch_to_fiber_no_sync
);
30 swapcontext(&orig_uc
, &uc
);
31 __tsan_destroy_fiber(fiber
);
32 fprintf(stderr
, "PASS\n");
36 // CHECK: WARNING: ThreadSanitizer: data race