# HG changeset patch # User rkennke # Date 1554739754 -7200 # Mon Apr 08 18:09:14 2019 +0200 # Node ID fc882e3a047a2b872450ad0811ae31701c9032cf # Parent 542735f2a53e74c5e1327c527c9da3dc6769b491 8222125: Shenandoah: Crash when running with ShenandoahParallelSafepointThreads=1 diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -1204,7 +1204,9 @@ void ShenandoahHeap::gc_threads_do(ThreadClosure* tcl) const { workers()->threads_do(tcl); - _safepoint_workers->threads_do(tcl); + if (_safepoint_workers != NULL) { + _safepoint_workers->threads_do(tcl); + } if (ShenandoahStringDedup::is_enabled()) { ShenandoahStringDedup::threads_do(tcl); } diff --git a/test/hotspot/jtreg/gc/shenandoah/options/TestSingleSafepointWorker.java b/test/hotspot/jtreg/gc/shenandoah/options/TestSingleSafepointWorker.java new file mode 100644 --- /dev/null +++ b/test/hotspot/jtreg/gc/shenandoah/options/TestSingleSafepointWorker.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019, Red Hat, Inc. All rights reserved. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/* + * @test TestSingleSafepointWorker + * @key gc + * @requires vm.gc.Shenandoah + * + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:ShenandoahParallelSafepointThreads=1 -Xmx128m TestSingleSafepointWorker + */ + +public class TestSingleSafepointWorker { + static final long TARGET_MB = Long.getLong("target", 1000); // 1 Gb allocation + + static volatile Object sink; + + public static void main(String[] args) throws Exception { + long count = TARGET_MB * 1024 * 1024 / 16; + for (long c = 0; c < count; c++) { + sink = new Object(); + } + } +}