Disable the from-space memory protection under debug/gcstress.
Temporarily for diagnosing the odd memory protection issue on the build
server.
Bug: 31172841
Test: test-art-host with SS and with SS/gcstress.
Change-Id: I915fcdc451ee92b5487c1fcbf8186767830ef1ad
diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc
index 7a4c025..0532126 100644
--- a/runtime/gc/collector/semi_space.cc
+++ b/runtime/gc/collector/semi_space.cc
@@ -265,16 +265,20 @@
RecordFree(ObjectBytePair(from_objects - to_objects, from_bytes - to_bytes));
// Clear and protect the from space.
from_space_->Clear();
- if (kProtectFromSpace && !from_space_->IsRosAllocSpace()) {
- // Protect with PROT_NONE.
- VLOG(heap) << "Protecting from_space_ : " << *from_space_;
- from_space_->GetMemMap()->Protect(PROT_NONE);
- } else {
- // If RosAllocSpace, we'll leave it as PROT_READ here so the
- // rosaloc verification can read the metadata magic number and
- // protect it with PROT_NONE later in FinishPhase().
- VLOG(heap) << "Protecting from_space_ with PROT_READ : " << *from_space_;
- from_space_->GetMemMap()->Protect(PROT_READ);
+ // b/31172841. Temporarily disable the from-space protection under gcstress mode with debug build
+ // due to some protection issue in the build server.
+ if (kProtectFromSpace && !(kIsDebugBuild && heap_->gc_stress_mode_)) {
+ if (!from_space_->IsRosAllocSpace()) {
+ // Protect with PROT_NONE.
+ VLOG(heap) << "Protecting from_space_ : " << *from_space_;
+ from_space_->GetMemMap()->Protect(PROT_NONE);
+ } else {
+ // If RosAllocSpace, we'll leave it as PROT_READ here so the
+ // rosaloc verification can read the metadata magic number and
+ // protect it with PROT_NONE later in FinishPhase().
+ VLOG(heap) << "Protecting from_space_ with PROT_READ : " << *from_space_;
+ from_space_->GetMemMap()->Protect(PROT_READ);
+ }
}
heap_->PreSweepingGcVerification(this);
if (swap_semi_spaces_) {
@@ -790,9 +794,13 @@
void SemiSpace::FinishPhase() {
TimingLogger::ScopedTiming t(__FUNCTION__, GetTimings());
- if (kProtectFromSpace && from_space_->IsRosAllocSpace()) {
- VLOG(heap) << "Protecting from_space_ with PROT_NONE : " << *from_space_;
- from_space_->GetMemMap()->Protect(PROT_NONE);
+ // b/31172841. Temporarily disable the from-space protection under gcstress mode with debug build
+ // due to some protection issue in the build server.
+ if (kProtectFromSpace && !(kIsDebugBuild && heap_->gc_stress_mode_)) {
+ if (from_space_->IsRosAllocSpace()) {
+ VLOG(heap) << "Protecting from_space_ with PROT_NONE : " << *from_space_;
+ from_space_->GetMemMap()->Protect(PROT_NONE);
+ }
}
// Null the "to" and "from" spaces since compacting from one to the other isn't valid until
// further action is done by the heap.