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
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc
index 771f8ed..3781c6f 100644
--- a/runtime/mem_map.cc
+++ b/runtime/mem_map.cc
@@ -157,6 +157,8 @@
     }
     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 @@
     *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