OSDN Git Service

ART: Fix memory unmapped twice issue in ElfFile::Load(bool)
authorJim_Guo <jim_guo@htc.com>
Mon, 28 Apr 2014 03:11:57 +0000 (11:11 +0800)
committerBrian Carlstrom <bdc@google.com>
Tue, 5 Aug 2014 05:47:48 +0000 (22:47 -0700)
commitac304133ab4b988777bcc5ad12257cbb99c3871e
tree517e9912d8d202fb125a47b526ced9e5d399bcf5
parent27a10f618357cf85cc0677a04f0a5a3a8a437aed
ART: Fix memory unmapped twice issue in ElfFile::Load(bool)

Root Cause:
  The overlapped memory region will be unmapped by
  (1) ~MemMap() of reservation MemMap (reserve) and
  (2) ~MemMap() of "reuse" MemMap (segment).
  Someone takes the memory region after (1) and it will be unmapped in (2).
  So, SIGSEGV occurs when using the unmapped memory region.

Solution:
  Fixes this issue by skip unmap "reuse" MemMap in destructor.
  And always create reservation MemMap before "reuse" MemMap. (It also solved
  the fixupELF case which does not reserve the whole needed memory region).

Bug: 16486685

(cherry picked from commit a62a588a9202f69e53fbeb3045ea8ea5ec2587f8)

Change-Id: Icb83c8e87fa168027d9d8adb34925000399d3d2a
runtime/elf_file.cc
runtime/mem_map.cc
runtime/mem_map.h