diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:48 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:48 +0000 |
commit | 93c1b73a09a52d4a265f683bf1954b08bb430049 (patch) | |
tree | 5543464d74945196cc890e9d9099e5d0660df7eb /test/lsan/TestCases/Linux/fork_with_threads.cc | |
parent | 0d8e7490d6e8a13a8f0977d9b7771803b9f64ea0 (diff) | |
download | src-93c1b73a09a52d4a265f683bf1954b08bb430049.tar.gz src-93c1b73a09a52d4a265f683bf1954b08bb430049.zip |
Vendor import of compiler-rt trunk r338150:vendor/compiler-rt/compiler-rt-trunk-r338150
Notes
Notes:
svn path=/vendor/compiler-rt/dist/; revision=336817
svn path=/vendor/compiler-rt/compiler-rt-trunk-r338150/; revision=336818; tag=vendor/compiler-rt/compiler-rt-trunk-r338150
Diffstat (limited to 'test/lsan/TestCases/Linux/fork_with_threads.cc')
-rw-r--r-- | test/lsan/TestCases/Linux/fork_with_threads.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/lsan/TestCases/Linux/fork_with_threads.cc b/test/lsan/TestCases/Linux/fork_with_threads.cc new file mode 100644 index 000000000000..221c5d249d77 --- /dev/null +++ b/test/lsan/TestCases/Linux/fork_with_threads.cc @@ -0,0 +1,35 @@ +// Test forked process does not run lsan. +// RUN: %clangxx_lsan %s -o %t && %run %t 2>&1 | FileCheck %s + +#include <pthread.h> +#include <stdlib.h> +#include <sys/wait.h> +#include <unistd.h> + +static pthread_barrier_t barrier; + +// CHECK-NOT: SUMMARY: {{(Leak|Address)}}Sanitizer: +static void *thread_func(void *arg) { + void *buffer = malloc(1337); + pthread_barrier_wait(&barrier); + for (;;) + pthread_yield(); + return 0; +} + +int main() { + pthread_barrier_init(&barrier, 0, 2); + pthread_t tid; + int res = pthread_create(&tid, 0, thread_func, 0); + pthread_barrier_wait(&barrier); + pthread_barrier_destroy(&barrier); + + pid_t pid = fork(); + if (pid > 0) { + int status = 0; + waitpid(pid, &status, 0); + } + return 0; +} + +// CHECK: WARNING: LeakSanitizer is disabled in forked process |