From 39c12d4d20bfbd1c4b6efac0e7ca70ed631ab27d Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Tue, 6 Dec 2016 16:46:37 -0800 Subject: [PATCH] Fix CC DCHECK failure in 152-gc-and-run-finalization. This fixes the second crash trace in 33389022#1. Load the referent once which avoids passing nullptr to IsMarked(). It's still racey but it's okay because leaving a Reference with a cleared referent gray is fine, if not optimal performance-wise. Bug: 33389022 Bug: 12687968 Test: test-art-host with CC. 152 in a loop. Change-Id: I2b389022175e38bdc40518b9553a2f5180dbc649 --- runtime/gc/collector/concurrent_copying.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc index fbab73f02..b8899137b 100644 --- a/runtime/gc/collector/concurrent_copying.cc +++ b/runtime/gc/collector/concurrent_copying.cc @@ -1360,9 +1360,10 @@ inline void ConcurrentCopying::ProcessMarkStackRef(mirror::Object* to_ref) { << " is_marked=" << IsMarked(to_ref); } #ifdef USE_BAKER_OR_BROOKS_READ_BARRIER + mirror::Object* referent = nullptr; if (UNLIKELY((to_ref->GetClass()->IsTypeOfReferenceClass() && - to_ref->AsReference()->GetReferent() != nullptr && - !IsInToSpace(to_ref->AsReference()->GetReferent())))) { + (referent = to_ref->AsReference()->GetReferent()) != nullptr && + !IsInToSpace(referent)))) { // Leave this reference gray in the queue so that GetReferent() will trigger a read barrier. We // will change it to white later in ReferenceQueue::DequeuePendingReference(). DCHECK(to_ref->AsReference()->GetPendingNext() != nullptr) << "Left unenqueued ref gray " << to_ref; -- 2.11.0