[compiler-rt] 3cc39f7 - [test][sanitizer] Add pthread_join in child
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 14 16:39:01 PST 2023
Author: Vitaly Buka
Date: 2023-12-14T16:38:35-08:00
New Revision: 3cc39f7d22965edfa79aacc959549d3b9b3a5fa6
URL: https://github.com/llvm/llvm-project/commit/3cc39f7d22965edfa79aacc959549d3b9b3a5fa6
DIFF: https://github.com/llvm/llvm-project/commit/3cc39f7d22965edfa79aacc959549d3b9b3a5fa6.diff
LOG: [test][sanitizer] Add pthread_join in child
Call dangerous code on main thread as well.
And use _exit() to avoid any issues during regular process cleanup.
And disable TSAN as it does not lock allocator yet.
Added:
Modified:
compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
Removed:
################################################################################
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
index 226e9c133ab3fc..d1ee0f9e6047f3 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
@@ -6,6 +6,9 @@
// FIXME: It probably hangs on this platform.
// UNSUPPORTED: ppc
+// FIXME: TSAN does not lock allocator.
+// UNSUPPORTED: tsan
+
// Forking in multithread environment is unsupported. However we already have
// some workarounds, and will add more, so this is the test.
// The test try to check two things:
@@ -35,7 +38,8 @@ void ShouldNotDeadlock() {
__lsan_disable();
void *volatile p = malloc(10);
__lsan_do_recoverable_leak_check();
- free(p);
+ // Allocator still in broken state, `free` may report errors.
+ // free(p);
__lsan_enable();
}
@@ -80,14 +84,18 @@ int main(void) {
perror("fork");
return -1;
case 0:
+ ShouldNotDeadlock();
while (pthread_create(&thread_id, 0, &inchild, 0) != 0) {
}
+ pthread_join(thread_id, NULL);
+ _exit(0);
break;
default: {
int status;
pid_t child = waitpid(pid, &status, /*options=*/0);
assert(pid == child);
- assert(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+ assert(WIFEXITED(status));
+ assert(WEXITSTATUS(status) == 0);
break;
}
}
More information about the llvm-commits
mailing list