summaryrefslogtreecommitdiff
path: root/src/memory_region_map.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory_region_map.cc')
-rw-r--r--src/memory_region_map.cc32
1 files changed, 9 insertions, 23 deletions
diff --git a/src/memory_region_map.cc b/src/memory_region_map.cc
index 3f8509f..17599af 100644
--- a/src/memory_region_map.cc
+++ b/src/memory_region_map.cc
@@ -194,15 +194,11 @@ void MemoryRegionMap::Init(int max_stack_depth) {
RAW_VLOG(10, "MemoryRegionMap Init increment done");
return;
}
- // Set our hooks and make sure no other hooks existed:
- if (MallocHook::SetMmapHook(MmapHook) != NULL ||
- MallocHook::SetMremapHook(MremapHook) != NULL ||
- MallocHook::SetSbrkHook(SbrkHook) != NULL ||
- MallocHook::SetMunmapHook(MunmapHook) != NULL) {
- RAW_LOG(FATAL, "Had other mmap/mremap/munmap/sbrk MallocHook-s set. "
- "Make sure only one of MemoryRegionMap and the other "
- "client is active.");
- }
+ // Set our hooks and make sure they were installed:
+ RAW_CHECK(MallocHook::AddMmapHook(&MmapHook), "");
+ RAW_CHECK(MallocHook::AddMremapHook(&MremapHook), "");
+ RAW_CHECK(MallocHook::AddSbrkHook(&SbrkHook), "");
+ RAW_CHECK(MallocHook::AddMunmapHook(&MunmapHook), "");
// We need to set recursive_insert since the NewArena call itself
// will already do some allocations with mmap which our hooks will catch
// recursive_insert allows us to buffer info about these mmap calls.
@@ -229,11 +225,10 @@ bool MemoryRegionMap::Shutdown() {
RAW_VLOG(10, "MemoryRegionMap Shutdown decrement done");
return true;
}
- CheckMallocHooks(); // we assume no other hooks
- MallocHook::SetMmapHook(NULL);
- MallocHook::SetMremapHook(NULL);
- MallocHook::SetSbrkHook(NULL);
- MallocHook::SetMunmapHook(NULL);
+ RAW_CHECK(MallocHook::RemoveMmapHook(&MmapHook), "");
+ RAW_CHECK(MallocHook::RemoveMremapHook(&MremapHook), "");
+ RAW_CHECK(MallocHook::RemoveSbrkHook(&SbrkHook), "");
+ RAW_CHECK(MallocHook::RemoveMunmapHook(&MunmapHook), "");
if (regions_) regions_->~RegionSet();
regions_ = NULL;
bool deleted_arena = LowLevelAlloc::DeleteArena(arena_);
@@ -247,15 +242,6 @@ bool MemoryRegionMap::Shutdown() {
return deleted_arena;
}
-void MemoryRegionMap::CheckMallocHooks() {
- if (MallocHook::GetMmapHook() != MmapHook ||
- MallocHook::GetMunmapHook() != MunmapHook ||
- MallocHook::GetMremapHook() != MremapHook ||
- MallocHook::GetSbrkHook() != SbrkHook) {
- RAW_LOG(FATAL, "Our mmap/mremap/munmap/sbrk MallocHook-s got changed.");
- }
-}
-
// Invariants (once libpthread_initialized is true):
// * While lock_ is not held, recursion_count_ is 0 (and
// lock_owner_tid_ is the previous owner, but we don't rely on