Files
clang-p2996/compiler-rt/test/lsan/TestCases/Linux/fork_and_leak.cpp
Fangrui Song 04dbb63400 [lsan][test] Enable many_tls_keys_pthread.cpp and disable swapcontext.cpp/fork_and_leak.cpp
With D98926, many_tls_keys_pthread.cpp appears to be working.

On glibc 2.30-0ubuntu2, swapcontext.cpp and Linux/fork_and_leak.cpp work fine
but they strangely fail on clang-cmake-aarch64-full
(https://lab.llvm.org/buildbot/#/builders/7/builds/2240).
Disable them for now.

Note: check-lsan was recently enabled on AArch64 in D98985. A test takes
10+ seconds. We should figure out the bottleneck.
2021-03-26 11:26:08 -07:00

27 lines
580 B
C++

// Test that leaks detected after forking without exec().
// RUN: %clangxx_lsan %s -o %t && not %run %t 2>&1 | FileCheck %s
/// Fails on clang-cmake-aarch64-full (glibc 2.27-3ubuntu1.4).
// UNSUPPORTED: aarch64
#include <assert.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
int main() {
pid_t pid = fork();
assert(pid >= 0);
if (pid > 0) {
int status = 0;
waitpid(pid, &status, 0);
assert(WIFEXITED(status));
return WEXITSTATUS(status);
} else {
malloc(1337);
// CHECK: LeakSanitizer: detected memory leaks
}
return 0;
}