From 02d97c3727a4c7fb611b73fac1a0ff19568de2c9 Mon Sep 17 00:00:00 2001 From: Jeff Hao Date: Mon, 14 Mar 2016 18:50:49 -0700 Subject: [PATCH] Fix zygote handling of when secondary image is out of date. Simple fix for case when primary image is current, but a secondary image is out of date. Will want to do a cleaner fix in the future. Bug: 27340451 (cherry-picked from commit b8510d2311964489342d8875ef7f5b681ba874b4) Change-Id: I034f001834d84b2a4aa367da722543091a2a7b3a --- runtime/gc/space/image_space.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc index 895d3d373..5ff1cb7a2 100644 --- a/runtime/gc/space/image_space.cc +++ b/runtime/gc/space/image_space.cc @@ -444,8 +444,16 @@ ImageSpace* ImageSpace::CreateBootImage(const char* image_location, // Whether we can write to the cache. success = false; } else if (secondary_image) { - reason = "Should not have to patch secondary image."; - success = false; + if (Runtime::Current()->IsZygote()) { + // Secondary image is out of date. Clear cache and exit to let it retry from scratch. + LOG(ERROR) << "Cannot patch secondary image '" << image_location + << "', clearing dalvik_cache and restarting zygote."; + PruneDalvikCache(image_isa); + _exit(1); + } else { + reason = "Should not have to patch secondary image."; + success = false; + } } else { // Try to relocate. success = RelocateImage(image_location, cache_filename.c_str(), image_isa, &reason); -- 2.11.0