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 <earthdok@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mstarzinger@chromium.org 2014-01-14 14:00:29 +00:00
parent be4c1bdac2
commit f5d050bcea

View File

@ -57,6 +57,10 @@
#include <asm/sigcontext.h>
#endif
#if defined(LEAK_SANITIZER)
#include <sanitizer/lsan_interface.h>
#endif
#undef MAP_TYPE
#include "v8.h"
@ -348,6 +352,9 @@ VirtualMemory::VirtualMemory(size_t size, size_t alignment)
address_ = static_cast<void*>(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;
}