# HG changeset patch # User kbarrett # Date 1415731140 18000 # Node ID 4e4ebe50c8e39a297ad9bc21c9717c2a7777b8e1 # Parent b2399f0d9611276771a4b4c1f606806b78bd99aa 8062036: ConcurrentMarkThread::slt may be invoked before ConcurrentMarkThread::makeSurrogateLockerThread causing intermittent crashes Summary: Suppress gc_alot during VM init, improve error for SLT uninitialized. Reviewed-by: jmasa, brutisso, tschatzl diff -r b2399f0d9611 -r 4e4ebe50c8e3 src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Mon Nov 17 16:36:09 2014 +0000 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Tue Nov 11 13:39:00 2014 -0500 @@ -50,8 +50,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() { diff -r b2399f0d9611 -r 4e4ebe50c8e3 src/share/vm/gc_implementation/g1/vm_operations_g1.cpp --- a/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp Mon Nov 17 16:36:09 2014 +0000 +++ b/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp Tue Nov 11 13:39:00 2014 -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() { diff -r b2399f0d9611 -r 4e4ebe50c8e3 src/share/vm/gc_implementation/shared/concurrentGCThread.cpp --- a/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp Mon Nov 17 16:36:09 2014 +0000 +++ b/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp Tue Nov 11 13:39:00 2014 -0500 @@ -137,6 +137,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"); diff -r b2399f0d9611 -r 4e4ebe50c8e3 src/share/vm/gc_implementation/shared/concurrentGCThread.hpp --- a/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp Mon Nov 17 16:36:09 2014 +0000 +++ b/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp Tue Nov 11 13:39:00 2014 -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; } diff -r b2399f0d9611 -r 4e4ebe50c8e3 src/share/vm/runtime/interfaceSupport.cpp --- a/src/share/vm/runtime/interfaceSupport.cpp Mon Nov 17 16:36:09 2014 +0000 +++ b/src/share/vm/runtime/interfaceSupport.cpp Tue Nov 11 13:39:00 2014 -0500 @@ -85,7 +85,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;