From d833acdb5febdad3e502d1c2b1ecd70643f263ef Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Mon, 27 Aug 2018 17:26:28 +0000 Subject: [PATCH] Revert "[lsan] Do not check for leaks in the forked process" Users need leak reports in forks. This reverts commit r334036. llvm-svn: 340758 --- compiler-rt/lib/lsan/lsan_common.cc | 9 ------ .../test/lsan/TestCases/Linux/fork_with_threads.cc | 35 ---------------------- 2 files changed, 44 deletions(-) delete mode 100644 compiler-rt/test/lsan/TestCases/Linux/fork_with_threads.cc diff --git a/compiler-rt/lib/lsan/lsan_common.cc b/compiler-rt/lib/lsan/lsan_common.cc index 012a673..eaa5cad 100644 --- a/compiler-rt/lib/lsan/lsan_common.cc +++ b/compiler-rt/lib/lsan/lsan_common.cc @@ -100,8 +100,6 @@ static SuppressionContext *GetSuppressionContext() { static InternalMmapVector *root_regions; -static uptr initialized_for_pid; - InternalMmapVector const *GetRootRegions() { return root_regions; } void InitializeRootRegions() { @@ -115,7 +113,6 @@ const char *MaybeCallLsanDefaultOptions() { } void InitCommonLsan() { - initialized_for_pid = internal_getpid(); InitializeRootRegions(); if (common_flags()->detect_leaks) { // Initialization which can fail or print warnings should only be done if @@ -571,12 +568,6 @@ static void CheckForLeaksCallback(const SuspendedThreadsList &suspended_threads, static bool CheckForLeaks() { if (&__lsan_is_turned_off && __lsan_is_turned_off()) return false; - if (initialized_for_pid != internal_getpid()) { - // If process was forked and it had threads we fail to detect references - // from other threads. - Report("WARNING: LeakSanitizer is disabled in forked process.\n"); - return false; - } EnsureMainThreadIDIsCorrect(); CheckForLeaksParam param; param.success = false; diff --git a/compiler-rt/test/lsan/TestCases/Linux/fork_with_threads.cc b/compiler-rt/test/lsan/TestCases/Linux/fork_with_threads.cc deleted file mode 100644 index 221c5d2..0000000 --- a/compiler-rt/test/lsan/TestCases/Linux/fork_with_threads.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Test forked process does not run lsan. -// RUN: %clangxx_lsan %s -o %t && %run %t 2>&1 | FileCheck %s - -#include -#include -#include -#include - -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 -- 2.7.4