diff --git a/src/hotspot/share/services/threadService.cpp b/src/hotspot/share/services/threadService.cpp index f30b0c170a69a..ca41ca077f7f6 100644 --- a/src/hotspot/share/services/threadService.cpp +++ b/src/hotspot/share/services/threadService.cpp @@ -1278,6 +1278,7 @@ class GetThreadSnapshotHandshakeClosure: public HandshakeClosure { if (is_virtual) { // mounted vthread, use carrier thread state oop carrier_thread = java_lang_VirtualThread::carrier_thread(_thread_h()); + assert(carrier_thread != nullptr, "should only get here for a mounted vthread"); _thread_status = java_lang_Thread::get_thread_status(carrier_thread); } else { _thread_status = java_lang_Thread::get_thread_status(_thread_h()); @@ -1477,7 +1478,17 @@ oop ThreadSnapshotFactory::get_thread_snapshot(jobject jthread, TRAPS) { carrier_thread = Handle(THREAD, java_lang_VirtualThread::carrier_thread(thread_h())); if (carrier_thread != nullptr) { + // Note: The java_thread associated with this carrier_thread may not be + // protected by the ThreadsListHandle above. There could have been an + // unmount and remount after the ThreadsListHandle above was created + // and before the JvmtiVTMSTransitionDisabler was created. However, as + // we have disabled transitions, if we are mounted on it, then it cannot + // terminate and so is safe to handshake with. java_thread = java_lang_Thread::thread(carrier_thread()); + } else { + // We may have previously found a carrier but the virtual thread has unmounted + // after that, so clear that previous reference. + java_thread = nullptr; } } else { java_thread = java_lang_Thread::thread(thread_h()); @@ -1554,4 +1565,3 @@ oop ThreadSnapshotFactory::get_thread_snapshot(jobject jthread, TRAPS) { } #endif // INCLUDE_JVMTI - diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 5784373637b49..84555a6edfb51 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -554,8 +554,6 @@ java/io/IO/IO.java 8337935 linux-pp # jdk_management -com/sun/management/HotSpotDiagnosticMXBean/DumpThreads.java 8364314 generic-all - com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all