--- old/src/hotspot/share/runtime/thread.cpp 2018-03-23 15:32:33.000000000 -0400 +++ new/src/hotspot/share/runtime/thread.cpp 2018-03-23 15:32:33.000000000 -0400 @@ -2392,11 +2392,13 @@ } #ifdef ASSERT -// verify the JavaThread has not yet been published in the Threads::list, and -// hence doesn't need protection from concurrent access at this stage +// Verify the JavaThread has not yet been published in the Threads::list, and +// hence doesn't need protection from concurrent access at this stage. void JavaThread::verify_not_published() { - ThreadsListHandle tlh; - assert(!tlh.includes(this), "JavaThread shouldn't have been published yet!"); + // Cannot create a ThreadsListHandle here and check !tlh.includes(this) + // since an unpublished JavaThread doesn't participate in the + // Thread-SMR protocol for keeping a ThreadsList alive. + assert(!on_thread_list(), "JavaThread shouldn't have been published yet!"); } #endif @@ -4254,7 +4256,13 @@ VMThread::destroy(); } - // clean up ideal graph printers + // Remember the Thread that is shutting down the VM because it needs + // to be immune to some of the sanity checks and policies that have + // to happen at VM shutdown time. + VM_Exit::set_shutdown_thread(thread); + + // Clean up ideal graph printers after the VMThread has started + // the final safepoint which will block all the Compiler threads. #if defined(COMPILER2) && !defined(PRODUCT) IdealGraphPrinter::clean_up(); #endif