From e302088f50244f10c90e5f40b6e05c9574c4cf32 Mon Sep 17 00:00:00 2001 From: Alex Light Date: Mon, 13 May 2019 16:35:02 -0700 Subject: Call ReferenceQueue add outside of active GC block We were calling ReferenceQueue.add within the runtime GC active block. This caused java code to be run and could (potentially) cause deadlocks with JVMTI and debuggers. To fix this we collect the cleared references during the GC and only enqueue them after FinishGC. Test: ./test.py --host Test: atest CtsJdwpTunnelHostTestCases # with goldfish emulator Test: ./art/tools/run-libjdwp-tests.sh --mode=host Bug: 132460313 Change-Id: I276870096fb60a06afba7f850325d06709227b8e --- runtime/gc/reference_processor.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'runtime/gc/reference_processor.h') diff --git a/runtime/gc/reference_processor.h b/runtime/gc/reference_processor.h index c1c9a3c833..54de5cc572 100644 --- a/runtime/gc/reference_processor.h +++ b/runtime/gc/reference_processor.h @@ -61,7 +61,9 @@ class ReferenceProcessor { // Decode the referent, may block if references are being processed. ObjPtr GetReferent(Thread* self, ObjPtr reference) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::reference_processor_lock_); - void EnqueueClearedReferences(Thread* self) REQUIRES(!Locks::mutator_lock_); + // Collects the cleared references and returns a task, to be executed after FinishGC, that will + // enqueue all of them. + SelfDeletingTask* CollectClearedReferences(Thread* self) REQUIRES(!Locks::mutator_lock_); void DelayReferenceReferent(ObjPtr klass, ObjPtr ref, collector::GarbageCollector* collector) -- cgit v1.2.3-59-g8ed1b