OSDN Git Service

Fix destruction order in Dex2Oat.
authorVladimir Marko <vmarko@google.com>
Tue, 20 Oct 2015 10:20:09 +0000 (11:20 +0100)
committerVladimir Marko <vmarko@google.com>
Tue, 20 Oct 2015 13:25:21 +0000 (14:25 +0100)
commit307dac9ac366ebb454d5e68d5681189b15035854
treee92df14bd45b3aed4f158bf562a8c0b0b0e8f48f
parent620021e643518dc93dc618d3e9df1c33ff8a491c
Fix destruction order in Dex2Oat.

In case of a failure (say, --image= pointing to non-existent
directory), the image_writer_ may not be destroyed in
CreateImageFile() and it will be destroyed in Dex2Oat's
destructor instead. However, ImageWriter owns a MemMap, so
it must be destroyed before MemMap::Shutdown() called from
Runtime's destructor. In release builds without leak checks,
we intentionally leak the runtime, so we don't hit the
destruction order issue. However, debug build was crashing
on the DCHECK(maps_ != nullptr) in MemMap destructor.

This change cleans up the destruction order and deliberately
leaks even more owned data in release builds without leak
checks.

Change-Id: Ib7f305bb676589d0379ecaafe6a53eeae208beaa
dex2oat/dex2oat.cc