JDK-8312498 : Thread::getState and JVM TI GetThreadState should return TIMED_WAITING virtual thread is timed parked
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 19,21,22
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2023-07-21
  • Updated: 2024-07-25
  • Resolved: 2023-09-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21 JDK 22
21.0.4-oracleFixed 22 b16Fixed
Related Reports
Relates :  
Description
If a virtual thread is in a timed-parked (LockSupport.parkNanos) then Thread::getThread returns WAITING rather than TIMED_WAITING. The Thread::getState method was added for monitoring and management purposes but should be fixed.

JVM TI GetThreadState has a similar issue. It returns the state with the JVMTI_THREAD_STATE_WAITING_INDEFINITELY rather than JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT bit set.
Comments
[jdk21u-fix-request] Approval Request from Aleksey Shipilëv Fixes what thread state VT reports when timed-parked. This fixes the actual Loom bug. In mainline since Sep 2023. There is a bug tail, JDK-8322818. The fix is part of large atomic change, see 21u PR.
15-02-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/245 Date: 2024-02-08 11:17:02 +0000
15-02-2024

Changeset: 4461eeb3 Author: Alan Bateman <alanb@openjdk.org> Date: 2023-09-19 10:58:12 +0000 URL: https://git.openjdk.org/jdk/commit/4461eeb31d5ccc89e304329a7dccb9cb130713fc
19-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14978 Date: 2023-07-21 18:01:45 +0000
24-07-2023