summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/gc/reference_queue.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/runtime/gc/reference_queue.cc b/runtime/gc/reference_queue.cc
index 0c0ab6d212..56957baebf 100644
--- a/runtime/gc/reference_queue.cc
+++ b/runtime/gc/reference_queue.cc
@@ -115,10 +115,12 @@ mirror::Reference* ReferenceQueue::DequeuePendingReference() {
<< "ref=" << ref << " rb_ptr=" << ref->GetReadBarrierPointer();
}
mirror::Object* referent = ref->GetReferent<kWithoutReadBarrier>();
- CHECK(referent != nullptr) << "Reference should not have been enqueued if referent is null";
- CHECK(concurrent_copying->IsInToSpace(referent))
- << "ref=" << ref << " rb_ptr=" << ref->GetReadBarrierPointer()
- << " referent=" << referent;
+ // The referent could be null if it's cleared by a mutator (Reference.clear()).
+ if (referent != nullptr) {
+ CHECK(concurrent_copying->IsInToSpace(referent))
+ << "ref=" << ref << " rb_ptr=" << ref->GetReadBarrierPointer()
+ << " referent=" << referent;
+ }
}
}
return ref;