[PATCH] D52330: SafeStack: Fix flaky test (PR39001)
Vlad Tsyrklevich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 20 16:14:53 PDT 2018
vlad.tsyrklevich created this revision.
vlad.tsyrklevich added reviewers: jmorse, eugenis, vitalybuka.
Herald added subscribers: Sanitizers, llvm-commits, jfb, delcypher.
pthread_join() can return before a thread finishes exit()ing in the
kernel and a subsequent tgkill() can report the thread still alive.
Update the pthread-cleanup.c test to sleep and retry if it hits this
possible flake.
Thanks to Jeremy Morse for reporting.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D52330
Files:
test/safestack/pthread-cleanup.c
Index: test/safestack/pthread-cleanup.c
===================================================================
--- test/safestack/pthread-cleanup.c
+++ test/safestack/pthread-cleanup.c
@@ -29,18 +29,26 @@
if (pthread_join(t1, &t1_buffer))
abort();
+ // Stack has not yet been deallocated
memset(t1_buffer, 0, kBufferSize);
if (arg == 0)
return 0;
- if (pthread_create(&t2, NULL, start, NULL))
- abort();
- // Second thread destructor cleans up the first thread's stack.
- if (pthread_join(t2, NULL))
- abort();
-
- // should segfault here
- memset(t1_buffer, 0, kBufferSize);
+ for (int i = 0; i < 3; i++) {
+ if (pthread_create(&t2, NULL, start, NULL))
+ abort();
+ // Second thread destructor cleans up the first thread's stack.
+ if (pthread_join(t2, NULL))
+ abort();
+
+ // Should segfault here
+ memset(t1_buffer, 0, kBufferSize);
+
+ // PR39001: Re-try in the rare case that pthread_join() returns before the
+ // thread finishes exiting in the kernel--hence the tgkill() check for t1
+ // returns that it's alive despite pthread_join() returning.
+ sleep(1);
+ }
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52330.166379.patch
Type: text/x-patch
Size: 1160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180920/3f092006/attachment.bin>
More information about the llvm-commits
mailing list