From b272cd3013e046b7b001a091b0925b99a844e382 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Fri, 11 Apr 2014 16:42:46 -0700 Subject: [PATCH] Fix heap verification with SS/GSS. Since I had removed the SwapSemiSpaces it was trying to verify references in the from space of the semispace collector, which isn't necessarily valid. Bug: 13989162 Change-Id: I8e0b7119a1a53d63f2c71ecdb276290eda5bae07 --- runtime/gc/collector/semi_space.cc | 4 +++- runtime/gc/heap.cc | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc index 6e31cb7c0..ccb38c4dc 100644 --- a/runtime/gc/collector/semi_space.cc +++ b/runtime/gc/collector/semi_space.cc @@ -393,10 +393,10 @@ void SemiSpace::ReclaimPhase() { // Note: Freed bytes can be negative if we copy form a compacted space to a free-list backed // space. heap_->RecordFree(freed_objects, freed_bytes); + timings_.StartSplit("PreSweepingGcVerification"); heap_->PreSweepingGcVerification(this); timings_.EndSplit(); - { WriterMutexLock mu(self_, *Locks::heap_bitmap_lock_); // Reclaim unmarked objects. @@ -411,6 +411,8 @@ void SemiSpace::ReclaimPhase() { TimingLogger::ScopedSplit split("UnBindBitmaps", &timings_); GetHeap()->UnBindBitmaps(); } + // TODO: Do this before doing verification since the from space may have objects which weren't + // moved and point to dead objects. from_space_->Clear(); // Protect the from space. VLOG(heap) << "Protecting space " << *from_space_; diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index e44ec6ab3..64dafe72f 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -2403,9 +2403,11 @@ void Heap::PreSweepingGcVerification(collector::GarbageCollector* gc) { WriterMutexLock mu(self, *Locks::heap_bitmap_lock_); // Swapping bound bitmaps does nothing. gc->SwapBitmaps(); + SwapSemiSpaces(); if (!VerifyHeapReferences()) { LOG(FATAL) << "Pre sweeping " << gc->GetName() << " GC verification failed"; } + SwapSemiSpaces(); gc->SwapBitmaps(); } } -- 2.11.0