RFR: 8312498: Thread::getState and JVM TI GetThreadState should return TIMED_WAITING virtual thread is timed parked

Serguei Spitsyn sspitsyn at openjdk.org
Thu Jul 27 01:33:02 UTC 2023


On Fri, 21 Jul 2023 18:01:45 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> Thread::getState is an API for monitoring and management purposes to report the thread state. If a virtual thread is parked with LockSupport.parkNanos, its state is reported as  WAITING when it should be TIMED_WAITING. JVM TI GetThreadState has the same issue in that it returns JVMTI_THREAD_STATE_WAITING_INDEFINITELY instead of the JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT bit set. Not a very visible issue because JDWP maps both states to "WAIT" but it may be noticed by tools using other JVM TI agents.
> 
> The change is straight-forward, it's just additional state bit to indicate that park is timed. The existing virtual/ThreadAPI.java test is expanded to this scenario. A new test is added for JVM TI GetThreadState to test waiting/timed-waited cases (including pinned) as test coverage seems patchy here.

test/hotspot/jtreg/serviceability/jvmti/vthread/GetThreadState/libGetThreadStateTest.c line 50:

> 48:         (*env)->FatalError(env, "GetThreadState failed");
> 49:     }
> 50:     return state;

Normal indent for native code is 2.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14978#discussion_r1275634875


More information about the serviceability-dev mailing list