[llvm-commits] [compiler-rt] r162842 - /compiler-rt/trunk/lib/asan/lit_tests/Linux/clone_test.cc
Alexey Samsonov
samsonov at google.com
Wed Aug 29 08:48:14 PDT 2012
Author: samsonov
Date: Wed Aug 29 10:48:14 2012
New Revision: 162842
URL: http://llvm.org/viewvc/llvm-project?rev=162842&view=rev
Log:
[ASan] fix flakiness of Linux-specific clone_test: waitpid should better be provided with __WCLONE option, otherwise it didn't wait for the subprocess, returned -1, and we went crushing the subprocess stack
Modified:
compiler-rt/trunk/lib/asan/lit_tests/Linux/clone_test.cc
Modified: compiler-rt/trunk/lib/asan/lit_tests/Linux/clone_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/Linux/clone_test.cc?rev=162842&r1=162841&r2=162842&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/Linux/clone_test.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/Linux/clone_test.cc Wed Aug 29 10:48:14 2012
@@ -29,11 +29,20 @@
char *sp = child_stack + kStackSize; // Stack grows down.
printf("Parent: %p\n", sp);
pid_t clone_pid = clone(Child, sp, CLONE_FILES | CLONE_VM, NULL, 0, 0, 0);
- waitpid(clone_pid, NULL, 0);
- for (int i = 0; i < kStackSize; i++)
- child_stack[i] = i;
- int ret = child_stack[argc - 1];
- printf("PASSED\n");
- // CHECK: PASSED
- return ret;
+ int status;
+ pid_t wait_result = waitpid(clone_pid, &status, __WCLONE);
+ if (wait_result < 0) {
+ perror("waitpid");
+ return 0;
+ }
+ if (wait_result == clone_pid && WIFEXITED(status)) {
+ // Make sure the child stack was indeed unpoisoned.
+ for (int i = 0; i < kStackSize; i++)
+ child_stack[i] = i;
+ int ret = child_stack[argc - 1];
+ printf("PASSED\n");
+ // CHECK: PASSED
+ return ret;
+ }
+ return 0;
}
More information about the llvm-commits
mailing list