Verify there's no mem map gap for immune region not to break.
This adds code that verifies that there's no memory map gap between
the image space and the main space so that the immune region
functionality won't silently break. For example, if there's a gap and
a large object is allocated in that gap, the large object is
incorrectly part of the immune region and the marking breaks.
Bug: 14059466
Change-Id: Ie6ed82988d74b6d0562ebbbaac96ee43c15b14a6
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index a6093ca..1efabff 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -341,6 +341,17 @@
garbage_collectors_.push_back(concurrent_copying_collector_);
}
+ if (GetImageSpace() != nullptr && main_space_ != nullptr) {
+ // Check that there's no gap between the image space and the main
+ // space so that the immune region won't break (eg. due to a large
+ // object allocated in the gap).
+ bool no_gap = MemMap::CheckNoGaps(GetImageSpace()->GetMemMap(), main_space_->GetMemMap());
+ if (!no_gap) {
+ MemMap::DumpMaps(LOG(ERROR));
+ LOG(FATAL) << "There's a gap between the image space and the main space";
+ }
+ }
+
if (running_on_valgrind_) {
Runtime::Current()->GetInstrumentation()->InstrumentQuickAllocEntryPoints();
}