Merge "Fix heap corruption and verification."
diff --git a/runtime/gc/accounting/card_table-inl.h b/runtime/gc/accounting/card_table-inl.h
index 217360f..3b06f74 100644
--- a/runtime/gc/accounting/card_table-inl.h
+++ b/runtime/gc/accounting/card_table-inl.h
@@ -55,7 +55,7 @@
// scan_end is the byte after the last byte we scan.
DCHECK_LE(scan_end, reinterpret_cast<byte*>(bitmap->HeapLimit()));
byte* card_cur = CardFromAddr(scan_begin);
- byte* card_end = CardFromAddr(scan_end);
+ byte* card_end = CardFromAddr(AlignUp(scan_end, kCardSize));
CheckCardValid(card_cur);
CheckCardValid(card_end);
size_t cards_scanned = 0;
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 5d138d2..821d22f 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2483,7 +2483,6 @@
bool Heap::VerifyMissingCardMarks() {
Thread* self = Thread::Current();
Locks::mutator_lock_->AssertExclusiveHeld(self);
-
// We need to sort the live stack since we binary search it.
live_stack_->Sort();
// Since we sorted the allocation stack content, need to revoke all
@@ -2491,7 +2490,6 @@
RevokeAllThreadLocalAllocationStacks(self);
VerifyLiveStackReferences visitor(this);
GetLiveBitmap()->Visit(visitor);
-
// We can verify objects in the live stack since none of these should reference dead objects.
for (mirror::Object** it = live_stack_->Begin(); it != live_stack_->End(); ++it) {
if (!kUseThreadLocalAllocationStack || *it != nullptr) {
@@ -2689,7 +2687,7 @@
void Heap::PostGcVerification(collector::GarbageCollector* gc) {
if (verify_system_weaks_ || verify_post_gc_rosalloc_ || verify_post_gc_heap_) {
collector::GarbageCollector::ScopedPause pause(gc);
- PreGcVerificationPaused(gc);
+ PostGcVerificationPaused(gc);
}
}