Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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 google/sanitizers#836 Reviewers: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D47751 llvm-svn: 334036
- Loading branch information
1 parent
8f6d6c8
commit b89704f
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
compiler-rt/test/lsan/TestCases/Linux/fork_with_threads.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |