From 986254d25f1bdd47852181f9cd1be33cb9bbfd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Inf=C3=BChr?= Date: Tue, 19 May 2020 16:04:19 +0200 Subject: [PATCH] [heap] Introduce mutex for executable memory data structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lookups and updates to the executable_memory_ unordered_map need to be protected with mutex. Bug: v8:10315, v8:10546 Change-Id: Ic17e19d1e4fda18b99103a96052940e68e970586 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2208867 Reviewed-by: Ulan Degenbaev Commit-Queue: Dominik Inführ Cr-Commit-Position: refs/heads/master@{#67902} --- src/heap/memory-allocator.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/heap/memory-allocator.h b/src/heap/memory-allocator.h index 72f7943e1d..74d9b6bca5 100644 --- a/src/heap/memory-allocator.h +++ b/src/heap/memory-allocator.h @@ -330,12 +330,14 @@ class MemoryAllocator { } void RegisterExecutableMemoryChunk(MemoryChunk* chunk) { + base::MutexGuard guard(&executable_memory_mutex_); DCHECK(chunk->IsFlagSet(MemoryChunk::IS_EXECUTABLE)); DCHECK_EQ(executable_memory_.find(chunk), executable_memory_.end()); executable_memory_.insert(chunk); } void UnregisterExecutableMemoryChunk(MemoryChunk* chunk) { + base::MutexGuard guard(&executable_memory_mutex_); DCHECK_NE(executable_memory_.find(chunk), executable_memory_.end()); executable_memory_.erase(chunk); chunk->heap()->UnregisterUnprotectedMemoryChunk(chunk); @@ -396,6 +398,7 @@ class MemoryAllocator { // Data structure to remember allocated executable memory chunks. std::unordered_set executable_memory_; + base::Mutex executable_memory_mutex_; friend class heap::TestCodePageAllocatorScope;