diff options
Diffstat (limited to 'runtime/mem_map.cc')
| -rw-r--r-- | runtime/mem_map.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc index 2a019c5bae..2d3581da8f 100644 --- a/runtime/mem_map.cc +++ b/runtime/mem_map.cc @@ -134,11 +134,25 @@ static uintptr_t GenerateNextMemPos() { uintptr_t MemMap::next_mem_pos_ = GenerateNextMemPos(); #endif -// Return true if the address range is contained in a single /proc/self/map entry. -static bool ContainedWithinExistingMap(uint8_t* ptr, size_t size, - std::string* error_msg) { +// Return true if the address range is contained in a single memory map by either reading +// the maps_ variable or the /proc/self/map entry. +bool MemMap::ContainedWithinExistingMap(uint8_t* ptr, size_t size, std::string* error_msg) { uintptr_t begin = reinterpret_cast<uintptr_t>(ptr); uintptr_t end = begin + size; + + // There is a suspicion that BacktraceMap::Create is occasionally missing maps. TODO: Investigate + // further. + { + MutexLock mu(Thread::Current(), *Locks::mem_maps_lock_); + for (auto& pair : *maps_) { + MemMap* const map = pair.second; + if (begin >= reinterpret_cast<uintptr_t>(map->Begin()) && + end <= reinterpret_cast<uintptr_t>(map->End())) { + return true; + } + } + } + std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(getpid(), true)); if (map.get() == nullptr) { *error_msg = StringPrintf("Failed to build process map"); |