Snap for 4527419 from 53fcdf163a31e1af3a32af503afcd78d99f0c0ce to oc-m2-release
Change-Id: I11eee977bf620bfae5825b3d7335c803f921913d
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index fe0d35f..3aab4c6 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -1574,7 +1574,9 @@
if (!Runtime::Current()->IsImageDex2OatEnabled()) {
local_error_msg = "Patching disabled.";
} else if (secondary_image) {
- local_error_msg = "Cannot patch a secondary image.";
+ // We really want a working image. Prune and restart.
+ PruneDalvikCache(image_isa);
+ _exit(1);
} else if (ImageCreationAllowed(is_global_cache, image_isa, &local_error_msg)) {
bool patch_success =
RelocateImage(image_location, cache_filename.c_str(), image_isa, &local_error_msg);