diff options
author | Julian Lettner <julian.lettner@apple.com> | 2019-11-20 12:25:05 -0800 |
---|---|---|
committer | Julian Lettner <julian.lettner@apple.com> | 2019-11-21 15:19:31 -0800 |
commit | 0163329dbd6c687453a27f72e21512a8c151c5b3 (patch) | |
tree | f076b2236d432fcd0b202c687e023bf281c3187f /compiler-rt/test | |
parent | 8293f7434577e23a07284686f5b54079e22e6a91 (diff) | |
download | bcm5719-llvm-0163329dbd6c687453a27f72e21512a8c151c5b3.tar.gz bcm5719-llvm-0163329dbd6c687453a27f72e21512a8c151c5b3.zip |
[TSan] Make `mach_vm_allocate.c` test less flaky
rdar://57365733
Diffstat (limited to 'compiler-rt/test')
-rw-r--r-- | compiler-rt/test/tsan/Darwin/mach_vm_allocate.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler-rt/test/tsan/Darwin/mach_vm_allocate.c b/compiler-rt/test/tsan/Darwin/mach_vm_allocate.c index 5b1235201bd..2eab03f81a0 100644 --- a/compiler-rt/test/tsan/Darwin/mach_vm_allocate.c +++ b/compiler-rt/test/tsan/Darwin/mach_vm_allocate.c @@ -24,9 +24,11 @@ static int *alloc() { static void alloc_fixed(int *ptr) { mach_vm_address_t addr = (mach_vm_address_t)ptr; - kern_return_t res = - mach_vm_allocate(mach_task_self(), &addr, alloc_size, VM_FLAGS_FIXED); - assert(res == KERN_SUCCESS); + kern_return_t res; + // Re-allocation via VM_FLAGS_FIXED sporadically fails. + do { + res = mach_vm_allocate(mach_task_self(), &addr, alloc_size, VM_FLAGS_FIXED); + } while (res != KERN_SUCCESS); } static void dealloc(int *ptr) { @@ -39,8 +41,9 @@ static void *Thread(void *arg) { *global_ptr = 7; // Assignment 1 // We want to test that TSan does not report a race between the two - // assignments to global_ptr when memory is re-allocated here. The calls to - // the API itself are racy though, so ignore them. + // assignments to *global_ptr when the underlying memory is re-allocated + // between assignments. The calls to the API itself are racy though, so ignore + // them. AnnotateIgnoreWritesBegin(__FILE__, __LINE__); dealloc(global_ptr); alloc_fixed(global_ptr); |