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
Change-Id: I8f2538861d5c3fa7b9a04d2c3f516319cc060291
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index a78d3f7..0437f30 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -430,8 +430,7 @@
t2.NewTiming("Patching ELF");
std::string error_msg;
if (!PatchOatCode(driver.get(), oat_file, oat_location, &error_msg)) {
- LOG(ERROR) << "Failed to fixup ELF file " << oat_file->GetPath();
- LOG(ERROR) << "Error was: " << error_msg;
+ LOG(ERROR) << "Failed to fixup ELF file " << oat_file->GetPath() << ": " << error_msg;
return nullptr;
}
}