Check pages are readable after mprotect for SEGV_ACCERR diagnosis
We have a suspected mprotect issue where we see seg faults after pages
are mprotected with PROT_READ|PROT_WRITE with the SS collector on
host. This change attempts to see if earlier reads would cause faults
similarly.
Bug: 19894268
Change-Id: I041a663c6b55b747120915f73a0db5f566744ed8
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 8269f76..3c9312f 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2622,6 +2622,10 @@
}
if (collector != mark_compact_collector_ && collector != concurrent_copying_collector_) {
temp_space_->GetMemMap()->Protect(PROT_READ | PROT_WRITE);
+ if (kIsDebugBuild) {
+ // Try to read each page of the memory map in case mprotect didn't work properly b/19894268.
+ temp_space_->GetMemMap()->TryReadable();
+ }
CHECK(temp_space_->IsEmpty());
}
gc_type = collector::kGcTypeFull; // TODO: Not hard code this in.