Skip to content

Commit af5bf81

Browse files
author
Alex Menkov
committed
8310584: GetThreadState reports blocked and runnable for pinned suspended virtual threads
Reviewed-by: sspitsyn, dholmes
1 parent b4dce0d commit af5bf81

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/hotspot/share/prims/jvmtiEnvBase.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -799,12 +799,14 @@ JvmtiEnvBase::get_vthread_state(oop thread_oop, JavaThread* java_thread) {
799799
int vt_state = java_lang_VirtualThread::state(thread_oop);
800800
state = (jint)java_lang_VirtualThread::map_state_to_thread_status(vt_state);
801801
}
802-
if (ext_suspended && ((state & JVMTI_THREAD_STATE_ALIVE) != 0)) {
803-
state &= ~java_lang_VirtualThread::RUNNING;
804-
state |= JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE | JVMTI_THREAD_STATE_SUSPENDED;
805-
}
806-
if (interrupted) {
807-
state |= JVMTI_THREAD_STATE_INTERRUPTED;
802+
// Ensure the thread has not exited after retrieving suspended/interrupted values.
803+
if ((state & JVMTI_THREAD_STATE_ALIVE) != 0) {
804+
if (ext_suspended) {
805+
state |= JVMTI_THREAD_STATE_SUSPENDED;
806+
}
807+
if (interrupted) {
808+
state |= JVMTI_THREAD_STATE_INTERRUPTED;
809+
}
808810
}
809811
return state;
810812
}

test/hotspot/jtreg/serviceability/jvmti/vthread/GetThreadStateMountedTest/GetThreadStateMountedTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,11 @@ static void inNative() throws Exception {
238238

239239
public static void main(String[] args) throws Exception {
240240
runnable();
241-
/* "waiting" test cases fail due JDK-8310584
242241
blockedOnMonitorEnter();
243242
waiting(false);
244243
waiting(true);
245244
sleeping();
246245
parked();
247-
*/
248246
inNative();
249247

250248
int errCount = getErrorCount();

0 commit comments

Comments
 (0)