From 491b3b45634fffb0101244f7d491a1681e7e8002 Mon Sep 17 00:00:00 2001 From: William Kemper Date: Wed, 15 May 2024 16:53:04 +0000 Subject: [PATCH] 8332256: Shenandoah: Do not visit heap threads during shutdown Reviewed-by: shade, kdnilsen --- src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 870885b385c..53d4911797d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -1291,7 +1291,14 @@ void ShenandoahHeap::prepare_for_verify() { } void ShenandoahHeap::gc_threads_do(ThreadClosure* tcl) const { - tcl->do_thread(_control_thread); + if (_shenandoah_policy->is_at_shutdown()) { + return; + } + + if (_control_thread != nullptr) { + tcl->do_thread(_control_thread); + } + workers()->threads_do(tcl); if (_safepoint_workers != nullptr) { _safepoint_workers->threads_do(tcl); @@ -1848,7 +1855,7 @@ uint ShenandoahHeap::max_workers() { void ShenandoahHeap::stop() { // The shutdown sequence should be able to terminate when GC is running. - // Step 0. Notify policy to disable event recording. + // Step 0. Notify policy to disable event recording and prevent visiting gc threads during shutdown _shenandoah_policy->record_shutdown(); // Step 1. Notify control thread that we are in shutdown.