8332256: Shenandoah: Do not visit heap threads during shutdown

Reviewed-by: shade, kdnilsen
This commit is contained in:
William Kemper 2024-05-15 16:53:04 +00:00
parent 9c02c8dd71
commit 491b3b4563

View File

@ -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.