Change MemMap::maps_ to not be global variable
Runtime.exit() was causing globals to get destructed at the same time
that another thread was using it for allocating a new mem map.
Bug: 17962201
Change-Id: I400cb7b8141d858f3c08a6fe59a02838c04c6962
diff --git a/runtime/mem_map.h b/runtime/mem_map.h
index 314bf8d..df1222c 100644
--- a/runtime/mem_map.h
+++ b/runtime/mem_map.h
@@ -138,6 +138,9 @@
typedef AllocationTrackingMultiMap<void*, MemMap*, kAllocatorTagMaps> Maps;
+ static void Init() LOCKS_EXCLUDED(Locks::mem_maps_lock_);
+ static void Shutdown() LOCKS_EXCLUDED(Locks::mem_maps_lock_);
+
private:
MemMap(const std::string& name, uint8_t* begin, size_t size, void* base_begin, size_t base_size,
int prot, bool reuse) LOCKS_EXCLUDED(Locks::mem_maps_lock_);
@@ -167,7 +170,7 @@
#endif
// All the non-empty MemMaps. Use a multimap as we do a reserve-and-divide (eg ElfMap::Load()).
- static Maps maps_ GUARDED_BY(Locks::mem_maps_lock_);
+ static Maps* maps_ GUARDED_BY(Locks::mem_maps_lock_);
friend class MemMapTest; // To allow access to base_begin_ and base_size_.
};