[PATCH] D52330: SafeStack: Fix flaky test (PR39001)

Vlad Tsyrklevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 21 12:03:56 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT342763: SafeStack: Fix flaky test (PR39001) (authored by vlad.tsyrklevich, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52330?vs=166379&id=166532#toc

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.166532.patch
Type: text/x-patch
Size: 1160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180921/40fd65b5/attachment.bin>


More information about the llvm-commits mailing list