diff options
author | Vitaly Buka <vitalybuka@google.com> | 2018-06-05 18:15:57 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2018-06-05 18:15:57 +0000 |
commit | 7f47a0bea177db24ecfc75b9daf3874e39a869df (patch) | |
tree | fcbbc4f4a8d2601320a2e10014140b5d4ba10128 /test/lsan | |
parent | 1c2424a6bb396f18962689aed6b87f129e666176 (diff) |
[lsan] Do not check for leaks in the forked process
Summary:
If calling process had threads then forked process will fail to detect
references from them.
Fixes https://github.com/google/sanitizers/issues/836
Reviewers: alekseyshl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D47751
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334036 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/lsan')
-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 000000000..221c5d249 --- /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 |