--- old/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp 2014-11-07 17:32:36.833000000 -0500 +++ new/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp 2014-11-07 17:32:36.757000000 -0500 @@ -42,8 +42,12 @@ void VM_CMS_Operation::acquire_pending_list_lock() { // The caller may block while communicating // with the SLT thread in order to acquire/release the PLL. - ConcurrentMarkSweepThread::slt()-> - manipulatePLL(SurrogateLockerThread::acquirePLL); + SurrogateLockerThread* slt = ConcurrentMarkSweepThread::slt(); + if (slt != NULL) { + slt->manipulatePLL(SurrogateLockerThread::acquirePLL); + } else { + SurrogateLockerThread::report_missing_slt(); + } } void VM_CMS_Operation::release_and_notify_pending_list_lock() { --- old/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp 2014-11-07 17:32:37.288000000 -0500 +++ new/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp 2014-11-07 17:32:37.211000000 -0500 @@ -213,8 +213,12 @@ assert(_needs_pll, "don't call this otherwise"); // The caller may block while communicating // with the SLT thread in order to acquire/release the PLL. - ConcurrentMarkThread::slt()-> - manipulatePLL(SurrogateLockerThread::acquirePLL); + SurrogateLockerThread* slt = ConcurrentMarkThread::slt(); + if (slt != NULL) { + slt->manipulatePLL(SurrogateLockerThread::acquirePLL); + } else { + SurrogateLockerThread::report_missing_slt(); + } } void VM_CGC_Operation::release_and_notify_pending_list_lock() { --- old/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp 2014-11-07 17:32:37.702000000 -0500 +++ new/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp 2014-11-07 17:32:37.625000000 -0500 @@ -138,6 +138,13 @@ return res; } +void SurrogateLockerThread::report_missing_slt() { + vm_exit_during_initialization( + "GC before GC support fully initialized: " + "SLT is needed but has not yet been created."); + ShouldNotReachHere(); +} + void SurrogateLockerThread::manipulatePLL(SLT_msg_type msg) { MutexLockerEx x(&_monitor, Mutex::_no_safepoint_check_flag); assert(_buffer == empty, "Should be empty"); --- old/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp 2014-11-07 17:32:38.132000000 -0500 +++ new/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp 2014-11-07 17:32:38.055000000 -0500 @@ -93,6 +93,9 @@ public: static SurrogateLockerThread* make(TRAPS); + // Terminate VM with error message that SLT needed but not yet created. + static void report_missing_slt(); + SurrogateLockerThread(); bool is_hidden_from_external_view() const { return true; } --- old/src/share/vm/runtime/interfaceSupport.cpp 2014-11-07 17:32:38.561000000 -0500 +++ new/src/share/vm/runtime/interfaceSupport.cpp 2014-11-07 17:32:38.485000000 -0500 @@ -87,7 +87,7 @@ // Short-circuit any possible re-entrant gc-a-lot attempt if (thread->skip_gcalot()) return; - if (is_init_completed()) { + if (Threads::is_vm_complete()) { if (++_fullgc_alot_invocation < FullGCALotStart) { return; --- /dev/null 2014-11-07 13:36:26.372000000 -0500 +++ new/test/gc/TestScavengeALot_CMS.java 2014-11-07 17:32:38.886000000 -0500 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * 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 + * @bug 8062036 + * @summary ConcurrentMarkThread::slt may be invoked before ConcurrentMarkThread::makeSurrogateLockerThread causing intermittent crashes + * + * @key gc + * @requires vm.gc == "ConcMarkSweep" | vm.gc == "null" + * @run main/othervm -XX:+UseConcMarkSweepGC -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ScavengeALot -XX:SurvivorAlignmentInBytes=2k -Xmx10m TestScavengeALot_CMS + */ + +public class TestScavengeALot_CMS { + public static void main(String[] args) throws Exception { + System.out.println("Initialization complete."); + } +} --- /dev/null 2014-11-07 13:36:26.372000000 -0500 +++ new/test/gc/TestScavengeALot_G1.java 2014-11-07 17:32:39.273000000 -0500 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * 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 + * @bug 8062036 + * @summary ConcurrentMarkThread::slt may be invoked before ConcurrentMarkThread::makeSurrogateLockerThread causing intermittent crashes + * + * @key gc + * @requires vm.gc == "G1" | vm.gc == "null" + * @run main/othervm -XX:+UseG1GC -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+ScavengeALot -XX:SurvivorAlignmentInBytes=2k -Xmx10m TestScavengeALot_G1 + */ + +public class TestScavengeALot_G1 { + public static void main(String[] args) throws Exception { + System.out.println("Initialization complete."); + } +}