--- old/src/share/vm/runtime/vmThread.cpp Tue May 3 04:08:19 2016 +++ new/src/share/vm/runtime/vmThread.cpp Tue May 3 04:08:18 2016 @@ -308,10 +308,14 @@ _terminate_lock->notify(); } - // Deletion must be done synchronously by the JNI DestroyJavaVM thread - // so that the VMThread deletion completes before the main thread frees - // up the CodeHeap. + // Deletion is done synchronously by the JNI DestroyJavaVM thread + // so that the VMThread deletion doesn't race with that thread as it + // tears down VM resources. That means 'this' may already have been + // deallocated so we can't reference it. However we must do some cleanup + // ourselves before allowing the native thread to terminate + ThreadLocalStorage::set_thread(NULL); + }