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 /lib/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 'lib/lsan')
-rw-r--r-- | lib/lsan/lsan_common.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/lsan/lsan_common.cc b/lib/lsan/lsan_common.cc index eaa5cadc8..012a673c3 100644 --- a/lib/lsan/lsan_common.cc +++ b/lib/lsan/lsan_common.cc @@ -100,6 +100,8 @@ static SuppressionContext *GetSuppressionContext() { static InternalMmapVector<RootRegion> *root_regions; +static uptr initialized_for_pid; + InternalMmapVector<RootRegion> const *GetRootRegions() { return root_regions; } void InitializeRootRegions() { @@ -113,6 +115,7 @@ 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 @@ -568,6 +571,12 @@ 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; |