From f5d050bcea55554fb6db3691d57d2352bcaebd8c Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Tue, 14 Jan 2014 14:00:29 +0000 Subject: [PATCH] Annotate mapped memory regions for LeakSanitizer. Add in-code annotations for LeakSanitizer to treat any memory allocated through the VirtualMemory class as a source of live pointers. This change eliminates false positive leak reports when running Chromium under LSan. BUG=chromium:328552 R=mstarzinger@chromium.org LOG=Y Review URL: https://codereview.chromium.org/137313002 Patch from Sergey Matveev . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/platform-linux.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/platform-linux.cc b/src/platform-linux.cc index 0f1481b246..4e2017d093 100644 --- a/src/platform-linux.cc +++ b/src/platform-linux.cc @@ -57,6 +57,10 @@ #include #endif +#if defined(LEAK_SANITIZER) +#include +#endif + #undef MAP_TYPE #include "v8.h" @@ -348,6 +352,9 @@ VirtualMemory::VirtualMemory(size_t size, size_t alignment) address_ = static_cast(aligned_base); size_ = aligned_size; +#if defined(LEAK_SANITIZER) + __lsan_register_root_region(address_, size_); +#endif } @@ -397,6 +404,9 @@ void* VirtualMemory::ReserveRegion(size_t size) { if (result == MAP_FAILED) return NULL; +#if defined(LEAK_SANITIZER) + __lsan_register_root_region(result, size); +#endif return result; } @@ -433,6 +443,9 @@ bool VirtualMemory::UncommitRegion(void* base, size_t size) { bool VirtualMemory::ReleaseRegion(void* base, size_t size) { +#if defined(LEAK_SANITIZER) + __lsan_unregister_root_region(base, size); +#endif return munmap(base, size) == 0; }