[compiler-rt] r342763 - SafeStack: Fix flaky test (PR39001)
Vlad Tsyrklevich via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 21 12:02:32 PDT 2018
Author: vlad.tsyrklevich
Date: Fri Sep 21 12:02:32 2018
New Revision: 342763
URL: http://llvm.org/viewvc/llvm-project?rev=342763&view=rev
Log:
SafeStack: Fix flaky test (PR39001)
Summary:
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.
Reviewers: jmorse, eugenis, vitalybuka
Reviewed By: jmorse, vitalybuka
Subscribers: delcypher, jfb, llvm-commits, #sanitizers, kcc
Differential Revision: https://reviews.llvm.org/D52330
Modified:
compiler-rt/trunk/test/safestack/pthread-cleanup.c
Modified: compiler-rt/trunk/test/safestack/pthread-cleanup.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/safestack/pthread-cleanup.c?rev=342763&r1=342762&r2=342763&view=diff
==============================================================================
--- compiler-rt/trunk/test/safestack/pthread-cleanup.c (original)
+++ compiler-rt/trunk/test/safestack/pthread-cleanup.c Fri Sep 21 12:02:32 2018
@@ -29,18 +29,26 @@ int main(int argc, char **argv)
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();
+ 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);
+ // 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;
}
More information about the llvm-commits
mailing list