Add the following correct assert to the VTMS_vthread_end() function:
diff --git a/src/hotspot/share/prims/jvmtiThreadState.cpp b/src/hotspot/share/prims/jvmtiThreadState.cpp
index 651b65e2f33..a6d57e919e5 100644
--- a/src/hotspot/share/prims/jvmtiThreadState.cpp
+++ b/src/hotspot/share/prims/jvmtiThreadState.cpp
@@ -555,6 +555,7 @@ JvmtiVTMSTransitionDisabler::VTMS_vthread_end(jobject vthread) {
}
}
if (thread->jvmti_thread_state() != nullptr) {
+ assert(thread->jvmti_thread_state()->is_virtual(), "wrong JvmtiThreadState");
JvmtiExport::cleanup_thread(thread);
thread->set_jvmti_thread_state(nullptr);
oop vt = JNIHandles::resolve(vthread);
The assert will be fired:
.../workspace/open/src/hotspot/share/prims/jvmtiThreadState.cpp:559), pid=3457651, tid=3457682
# assert(thread->jvmti_thread_state()->is_virtual()) failed: wrong JvmtiThreadState
#
. . .
# Problematic frame:
# V [libjvm.so+0x11be891] JvmtiVTMSTransitionDisabler::VTMS_vthread_end(_jobject*)+0x2a1
#
. . .
--------------- T H R E A D ---------------
Current thread (0x00007fdbec0011e0): JavaThread "ForkJoinPool-1-worker-3" daemon [_thread_in_vm, id=3457682, stack(0x00007fdc35829000,0x00007fdc3592a000) (1028K)]
Stack: [0x00007fdc35829000,0x00007fdc3592a000], sp=0x00007fdc35928420, free space=1021k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x11be891] JvmtiVTMSTransitionDisabler::VTMS_vthread_end(_jobject*)+0x2a1 (jvmtiThreadState.cpp:559)
V [libjvm.so+0xfda604] JVM_VirtualThreadEnd+0xc4 (jvm.cpp:3937)
j java.lang.VirtualThread.notifyJvmtiEnd()V+0 java.base@21-internal
j java.lang.VirtualThread.run(Ljava/lang/Runnable;)V+96 java.base@21-internal
J 201 jdk.internal.vm.Continuation.enterSpecial(Ljdk/internal/vm/Continuation;ZZ)V java.base@21-internal (0 bytes) @ 0x00007fdc4c6dbd53 [0x00007fdc4c6dbbe0+0x0000000000000173]
J 360 c1 jdk.internal.vm.Continuation.run()V java.base@21-internal (586 bytes) @ 0x00007fdc44c81964 [0x00007fdc44c81040+0x0000000000000924]
J 359 c1 java.lang.VirtualThread.runContinuation()V java.base@21-internal (123 bytes) @ 0x00007fdc44c7f5c4 [0x00007fdc44c7f120+0x00000000000004a4]
J 358 c1 java.lang.VirtualThread$$Lambda+0x000000080104cf08.run()V java.base@21-internal (8 bytes) @ 0x00007fdc44c7ec04 [0x00007fdc44c7eb60+0x00000000000000a4]
j java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec()Z+4 java.base@21-internal
J 332 c1 java.util.concurrent.ForkJoinTask.doExec()I java.base@21-internal (37 bytes) @ 0x00007fdc44c742d4 [0x00007fdc44c74180+0x0000000000000154]
J 428 c2 java.util.concurrent.ForkJoinPool.scan(Ljava/util/concurrent/ForkJoinPool$WorkQueue;II)I java.base@21-internal (263 bytes) @ 0x00007fdc4c6ee1e4 [0x00007fdc4c6edee0+0x0000000000000304]
j java.util.concurrent.ForkJoinPool.runWorker(Ljava/util/concurrent/ForkJoinPool$WorkQueue;)V+35 java.base@21-internal
j java.util.concurrent.ForkJoinWorkerThread.run()V+31 java.base@21-internal
v ~StubRoutines::call_stub 0x00007fdc4c133d21
V [libjvm.so+0xe7f576] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x476 (javaCalls.cpp:415)
V [libjvm.so+0xe7fbb9] JavaCalls::call_virtual(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, JavaThread*)+0x329 (javaCalls.cpp:329)
V [libjvm.so+0xe7fdd5] JavaCalls::call_virtual(JavaValue*, Handle, Klass*, Symbol*, Symbol*, JavaThread*)+0x75 (javaCalls.cpp:191)
V [libjvm.so+0xfd65f6] thread_entry(JavaThread*, JavaThread*)+0x96 (jvm.cpp:2919)
V [libjvm.so+0xeb42fc] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:719)
V [libjvm.so+0x178fd68] Thread::call_run()+0xb8 (thread.cpp:217)
V [libjvm.so+0x148ca5a] thread_native_entry(Thread*)+0x11a (os_linux.cpp:740)
diff --git a/src/hotspot/share/prims/jvmtiThreadState.cpp b/src/hotspot/share/prims/jvmtiThreadState.cpp
index 651b65e2f33..a6d57e919e5 100644
--- a/src/hotspot/share/prims/jvmtiThreadState.cpp
+++ b/src/hotspot/share/prims/jvmtiThreadState.cpp
@@ -555,6 +555,7 @@ JvmtiVTMSTransitionDisabler::VTMS_vthread_end(jobject vthread) {
}
}
if (thread->jvmti_thread_state() != nullptr) {
+ assert(thread->jvmti_thread_state()->is_virtual(), "wrong JvmtiThreadState");
JvmtiExport::cleanup_thread(thread);
thread->set_jvmti_thread_state(nullptr);
oop vt = JNIHandles::resolve(vthread);
The assert will be fired:
.../workspace/open/src/hotspot/share/prims/jvmtiThreadState.cpp:559), pid=3457651, tid=3457682
# assert(thread->jvmti_thread_state()->is_virtual()) failed: wrong JvmtiThreadState
#
. . .
# Problematic frame:
# V [libjvm.so+0x11be891] JvmtiVTMSTransitionDisabler::VTMS_vthread_end(_jobject*)+0x2a1
#
. . .
--------------- T H R E A D ---------------
Current thread (0x00007fdbec0011e0): JavaThread "ForkJoinPool-1-worker-3" daemon [_thread_in_vm, id=3457682, stack(0x00007fdc35829000,0x00007fdc3592a000) (1028K)]
Stack: [0x00007fdc35829000,0x00007fdc3592a000], sp=0x00007fdc35928420, free space=1021k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x11be891] JvmtiVTMSTransitionDisabler::VTMS_vthread_end(_jobject*)+0x2a1 (jvmtiThreadState.cpp:559)
V [libjvm.so+0xfda604] JVM_VirtualThreadEnd+0xc4 (jvm.cpp:3937)
j java.lang.VirtualThread.notifyJvmtiEnd()V+0 java.base@21-internal
j java.lang.VirtualThread.run(Ljava/lang/Runnable;)V+96 java.base@21-internal
J 201 jdk.internal.vm.Continuation.enterSpecial(Ljdk/internal/vm/Continuation;ZZ)V java.base@21-internal (0 bytes) @ 0x00007fdc4c6dbd53 [0x00007fdc4c6dbbe0+0x0000000000000173]
J 360 c1 jdk.internal.vm.Continuation.run()V java.base@21-internal (586 bytes) @ 0x00007fdc44c81964 [0x00007fdc44c81040+0x0000000000000924]
J 359 c1 java.lang.VirtualThread.runContinuation()V java.base@21-internal (123 bytes) @ 0x00007fdc44c7f5c4 [0x00007fdc44c7f120+0x00000000000004a4]
J 358 c1 java.lang.VirtualThread$$Lambda+0x000000080104cf08.run()V java.base@21-internal (8 bytes) @ 0x00007fdc44c7ec04 [0x00007fdc44c7eb60+0x00000000000000a4]
j java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec()Z+4 java.base@21-internal
J 332 c1 java.util.concurrent.ForkJoinTask.doExec()I java.base@21-internal (37 bytes) @ 0x00007fdc44c742d4 [0x00007fdc44c74180+0x0000000000000154]
J 428 c2 java.util.concurrent.ForkJoinPool.scan(Ljava/util/concurrent/ForkJoinPool$WorkQueue;II)I java.base@21-internal (263 bytes) @ 0x00007fdc4c6ee1e4 [0x00007fdc4c6edee0+0x0000000000000304]
j java.util.concurrent.ForkJoinPool.runWorker(Ljava/util/concurrent/ForkJoinPool$WorkQueue;)V+35 java.base@21-internal
j java.util.concurrent.ForkJoinWorkerThread.run()V+31 java.base@21-internal
v ~StubRoutines::call_stub 0x00007fdc4c133d21
V [libjvm.so+0xe7f576] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x476 (javaCalls.cpp:415)
V [libjvm.so+0xe7fbb9] JavaCalls::call_virtual(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, JavaThread*)+0x329 (javaCalls.cpp:329)
V [libjvm.so+0xe7fdd5] JavaCalls::call_virtual(JavaValue*, Handle, Klass*, Symbol*, Symbol*, JavaThread*)+0x75 (javaCalls.cpp:191)
V [libjvm.so+0xfd65f6] thread_entry(JavaThread*, JavaThread*)+0x96 (jvm.cpp:2919)
V [libjvm.so+0xeb42fc] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:719)
V [libjvm.so+0x178fd68] Thread::call_run()+0xb8 (thread.cpp:217)
V [libjvm.so+0x148ca5a] thread_native_entry(Thread*)+0x11a (os_linux.cpp:740)