RFR: 8295976: GetThreadListStackTraces returns wrong state for blocked VirtualThread

Serguei Spitsyn sspitsyn at openjdk.org
Tue Jun 6 01:34:26 UTC 2023


The `GetThreadListStackTraces` returns `JVMTI_THREAD_STATE_RUNNABLE` for a VirtualThread blocked on a monitor when called for more than one thread. When called for a single VirtualThread it correctly returns a state that includes the `JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER` flag.
The `VM_GetThreadListStackTraces::doit` should call the `get_threadOop_and_JavaThread` instead of `cv_external_thread_to_JavaThread`. But the `get_threadOop_and_JavaThread` has a check for the current thread by comparing with the JavaThread::current() which does not work for a `VM_op`. Some refactoring of the `GetSingleStackTraceClosure` and `get_threadOop_and_JavaThread` was made to make it working for a `VM_op`.

Also, a minor bug in the `GetSingleStackTraceClosure::do_thread()` was discovered during testing.
A minor refactoring of the `GetSingleStackTraceClosure` was made to fix the issue.

Also, a new test was added to provide coverage:
 - `test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadListStackTracesTest`
 
Testing:
 - ran new test: `test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadListStackTracesTest`
 - TBD: tiers 1-6

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

Commit messages:
 - remove a trailing space in new ThreadListStackTracesTest.java
 - 8295976: GetThreadListStackTraces returns wrong state for blocked VirtualThread

Changes: https://git.openjdk.org/jdk/pull/14326/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14326&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8295976
  Stats: 241 lines in 5 files changed: 224 ins; 10 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/14326.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14326/head:pull/14326

PR: https://git.openjdk.org/jdk/pull/14326


More information about the hotspot-dev mailing list