8310584: GetThreadState reports blocked and runnable for pinned suspended virtual threads

Reviewed-by: sspitsyn, dholmes
This commit is contained in:
Alex Menkov 2023-07-18 20:16:41 +00:00
parent b4dce0d624
commit af5bf81754
2 changed files with 8 additions and 8 deletions
src/hotspot/share/prims
test/hotspot/jtreg/serviceability/jvmti/vthread/GetThreadStateMountedTest

@ -799,12 +799,14 @@ JvmtiEnvBase::get_vthread_state(oop thread_oop, JavaThread* java_thread) {
int vt_state = java_lang_VirtualThread::state(thread_oop);
state = (jint)java_lang_VirtualThread::map_state_to_thread_status(vt_state);
}
if (ext_suspended && ((state & JVMTI_THREAD_STATE_ALIVE) != 0)) {
state &= ~java_lang_VirtualThread::RUNNING;
state |= JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE | JVMTI_THREAD_STATE_SUSPENDED;
}
if (interrupted) {
state |= JVMTI_THREAD_STATE_INTERRUPTED;
// Ensure the thread has not exited after retrieving suspended/interrupted values.
if ((state & JVMTI_THREAD_STATE_ALIVE) != 0) {
if (ext_suspended) {
state |= JVMTI_THREAD_STATE_SUSPENDED;
}
if (interrupted) {
state |= JVMTI_THREAD_STATE_INTERRUPTED;
}
}
return state;
}

@ -238,13 +238,11 @@ public class GetThreadStateMountedTest {
public static void main(String[] args) throws Exception {
runnable();
/* "waiting" test cases fail due JDK-8310584
blockedOnMonitorEnter();
waiting(false);
waiting(true);
sleeping();
parked();
*/
inNative();
int errCount = getErrorCount();