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-pick of commit b8510d2311964489342d8875ef7f5b681ba874b4)
Change-Id: Ia6db863e3d3c72120630bcbae8d399a78dda2710
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 895d3d3..5ff1cb7 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -444,8 +444,16 @@
// 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);