diff options
| author | 2016-06-16 23:19:36 -0700 | |
|---|---|---|
| committer | 2016-06-16 23:19:36 -0700 | |
| commit | 56f8b5631ab2874dc2ec385802e38555acac0d90 (patch) | |
| tree | d418ebcc7af2f5035a175c46ef3b2a413b0bc69c | |
| parent | abdda2fb52eb7e9a6916899a913f78251d8ed277 (diff) | |
Add lock when iterating over BacktraceMap.
In order to avoid a race condition in the maps data, acquire
a read lock while iterating over the maps data.
Bug: 29387050
Change-Id: I7d484cac11503be060a9309bc886d1e5441a57b2
| -rw-r--r-- | runtime/mem_map.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc index 771f8ed290..3781c6f99d 100644 --- a/runtime/mem_map.cc +++ b/runtime/mem_map.cc @@ -157,6 +157,8 @@ bool MemMap::ContainedWithinExistingMap(uint8_t* ptr, size_t size, std::string* } return false; } + + ScopedBacktraceMapIteratorLock lock(map.get()); for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) { if ((begin >= it->start && begin < it->end) // start of new within old && (end > it->start && end <= it->end)) { // end of new within old @@ -180,6 +182,7 @@ static bool CheckNonOverlapping(uintptr_t begin, *error_msg = StringPrintf("Failed to build process map"); return false; } + ScopedBacktraceMapIteratorLock(map.get()); for (BacktraceMap::const_iterator it = map->begin(); it != map->end(); ++it) { if ((begin >= it->start && begin < it->end) // start of new within old || (end > it->start && end < it->end) // end of new within old |