VM: Tell lsan about mmap()ed regions used for our heap

The mmap()ed pages hold pointers to `VirtualMemory` objects. So we tell
lsan that the mmap()ed regions are roots.

R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2646363005 .
This commit is contained in:
Martin Kustermann
2017-01-24 12:47:36 +01:00
parent 89de0c9267
commit a9fbe2004d
4 changed files with 34 additions and 11 deletions
+22
View File
@@ -10,18 +10,40 @@
// Allow the use of ASan (AddressSanitizer). This is needed as ASan needs to be
// told about areas where the VM does the equivalent of a long-jump.
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
extern "C" void __asan_unpoison_memory_region(void*, size_t);
extern "C" void __lsan_register_root_region(const void* p, size_t size);
extern "C" void __lsan_unregister_root_region(const void* p, size_t size);
#define ASAN_UNPOISON(ptr, len) __asan_unpoison_memory_region(ptr, len)
#define LSAN_REGISTER_ROOT_REGION(ptr, len) \
__lsan_register_root_region(ptr, len)
#define LSAN_UNREGISTER_ROOT_REGION(ptr, len) \
__lsan_unregister_root_region(ptr, len)
#else // __has_feature(address_sanitizer)
#define ASAN_UNPOISON(ptr, len) \
do { \
} while (false && (ptr) == 0 && (len) == 0)
#define LSAN_REGISTER_ROOT_REGION(ptr, len) \
do { \
} while (false && (ptr) == 0 && (len) == 0)
#define LSAN_UNREGISTER_ROOT_REGION(ptr, len) \
do { \
} while (false && (ptr) == 0 && (len) == 0)
#endif // __has_feature(address_sanitizer)
#else // defined(__has_feature)
#define ASAN_UNPOISON(ptr, len) \
do { \
} while (false && (ptr) == 0 && (len) == 0)
#define LSAN_REGISTER_ROOT_REGION(ptr, len) \
do { \
} while (false && (ptr) == 0 && (len) == 0)
#define LSAN_UNREGISTER_ROOT_REGION(ptr, len) \
do { \
} while (false && (ptr) == 0 && (len) == 0)
#endif // defined(__has_feature)
#endif // RUNTIME_PLATFORM_ADDRESS_SANITIZER_H_
+2 -2
View File
@@ -18,8 +18,8 @@ cc/Fail0: Fail
cc/Fail1: Fail
cc/Fail2: Fail
cc/Dart2JSCompileAll: Crash # Issue 27369
cc/Dart2JSCompilerStats: Crash # Issue 27369
cc/Dart2JSCompileAll: Fail, Crash # Issue 27369
cc/Dart2JSCompilerStats: Fail, Crash # Issue 27369
cc/SNPrint_BadArgs: Skip
+10 -1
View File
@@ -4,6 +4,7 @@
#include "vm/pages.h"
#include "platform/address_sanitizer.h"
#include "platform/assert.h"
#include "vm/compiler_stats.h"
#include "vm/gc_marker.h"
@@ -69,6 +70,9 @@ HeapPage* HeapPage::Initialize(VirtualMemory* memory, PageType type) {
result->memory_ = memory;
result->next_ = NULL;
result->type_ = type;
LSAN_REGISTER_ROOT_REGION(result, sizeof(*result));
return result;
}
@@ -89,9 +93,14 @@ HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) {
void HeapPage::Deallocate() {
bool is_embedder_allocated = embedder_allocated();
if (!is_embedder_allocated) {
LSAN_UNREGISTER_ROOT_REGION(this, sizeof(*this));
}
// For a regular heap pages, the memory for this object will become
// unavailable after the delete below.
bool is_embedder_allocated = embedder_allocated();
delete memory_;
// For a heap page from a snapshot, the HeapPage object lives in the malloc
-8
View File
@@ -388,12 +388,4 @@ io/socket_info_ipv6_test: SkipByDesign
[ $builder_tag == asan && $arch == x64 ]
io/process_detached_test: Pass, Slow
io/stdout_bad_argument_test: Fail # Issue 28353
io/file_blocking_lock_test: Fail # Issue 28353
io/process_sync_test: RuntimeError
io/signals_test: RuntimeError
io/regress_7191_test: RuntimeError
io/named_pipe_script_test: RuntimeError
io/http_server_close_response_after_error_test: RuntimeError