JDK-8213236 : A partial removed/deleted JavaThread cannot transition
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-11-01
  • Updated: 2019-05-28
  • Resolved: 2018-11-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12
12 b19Fixed
Related Reports
Relates :  
Description
A JavaThread that is no longer on the threads list, and thus not included in safepoints should not do transitions.

V  [libjvm.dylib+0x5d2f9c]  HandshakeState::process_self_inner(JavaThread*)+0xf0
V  [libjvm.dylib+0xbe3519]  HandshakeState::process_by_self(JavaThread*)+0x39
V  [libjvm.dylib+0xbe33df]  ThreadStateTransition::transition_and_fence(JavaThread*, JavaThreadState, JavaThreadState)+0xbf
V  [libjvm.dylib+0x9bd732]  Monitor::lock(Thread*)+0x1ea
V  [libjvm.dylib+0xc719e4]  VMThread::wait_for_vm_thread_exit()+0x1c
V  [libjvm.dylib+0xbbb317]  Threads::destroy_vm()+0x1ad
V  [libjvm.dylib+0x6f50c3]  jni_DestroyJavaVM+0x16d
C  [libjli.dylib+0x4639]  JavaMain+0xa14

The above stack trace shows that the JavaThread calling
VMThread::wait_for_vm_thread_exit() is acquiring a lock
and following the safepoint protocol. However, at the point
that VMThread::wait_for_vm_thread_exit() is called, the
JavaThread has already exited:

src/hotspot/share/runtime/thread.cpp:
  before_exit(thread);

  thread->exit(true);

  // Stop VM thread.
  {
    // 4945125 The vm thread comes to a safepoint during exit.
    // GC vm_operations can get caught at the safepoint, and the
    // heap is unparseable if they are caught. Grab the Heap_lock
    // to prevent this. The GC vm_operations will not be able to
    // queue until after the vm thread is dead. After this point,
    // we'll never emerge out of the safepoint before the VM exits.

    MutexLocker ml(Heap_lock);

    VMThread::wait_for_vm_thread_exit();

So this call is a problem:

src/hotspot/share/runtime/vmThread.cpp:
void VMThread::wait_for_vm_thread_exit() {
  { MutexLocker mu(VMOperationQueue_lock);

Comments
FYI: This is a very rare race, we have test that can trigger, e.g. open/test/hotspot/jtreg/runtime/handshake/. But there is no way to create a reliable test for this.
09-01-2019

Not at all sure what this means. ??
01-11-2018