Commit dc5493f4 authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[Memory] Speculative fix for sanitizer flakiness.

- When allocating virtual memory, make sure addresses don't interfere
  with hard-coded sanitizer regions.

Bug: v8:7146
Change-Id: I5bcb664b32bf53c8581772fe329190da6033701f
Reviewed-on: https://chromium-review.googlesource.com/833171Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Bill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50208}
parent 5e6fd798
...@@ -206,14 +206,18 @@ size_t OS::CommitPageSize() { ...@@ -206,14 +206,18 @@ size_t OS::CommitPageSize() {
// static // static
void* OS::GetRandomMmapAddr() { void* OS::GetRandomMmapAddr() {
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER)
// Dynamic tools do not support custom mmap addresses.
return nullptr;
#else
uintptr_t raw_addr; uintptr_t raw_addr;
platform_random_number_generator.Pointer()->NextBytes(&raw_addr, platform_random_number_generator.Pointer()->NextBytes(&raw_addr,
sizeof(raw_addr)); sizeof(raw_addr));
#if defined(V8_USE_ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER)
// If random hint addresses interfere with address ranges hard coded in
// sanitizers, bad things happen. This address range is copied from TSAN
// source but works with all tools.
// See crbug.com/539863.
raw_addr &= 0x007fffff0000ULL;
raw_addr += 0x7e8000000000ULL;
#else
#if V8_TARGET_ARCH_X64 #if V8_TARGET_ARCH_X64
// Currently available CPUs have 48 bits of virtual addressing. Truncate // Currently available CPUs have 48 bits of virtual addressing. Truncate
// the hint address to 46 bits to give the kernel a fighting chance of // the hint address to 46 bits to give the kernel a fighting chance of
...@@ -267,8 +271,8 @@ void* OS::GetRandomMmapAddr() { ...@@ -267,8 +271,8 @@ void* OS::GetRandomMmapAddr() {
raw_addr += 0x20000000; raw_addr += 0x20000000;
#endif #endif
#endif #endif
return reinterpret_cast<void*>(raw_addr);
#endif #endif
return reinterpret_cast<void*>(raw_addr);
} }
// TODO(bbudge) Move Cygwin and Fuschia stuff into platform-specific files. // TODO(bbudge) Move Cygwin and Fuschia stuff into platform-specific files.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment