RFR: 8329109: Threads::print_on() tries to print CPU time for terminated GC threads
Richard Reingruber
rrich at openjdk.org
Thu Mar 28 07:40:43 UTC 2024
Make use of `Threads::threads_do()` if at a safepoint to print the threads.
`Threads::threads_do()` uses thread list iterators that don't visit terminated threads.
If a non-java thread is about to terminate, it waits for in progress iterations (see [NonJavaThread::remove_from_the_list](https://github.com/openjdk/jdk/blob/47f33a59eaaffc74881fcc9e29d13ff9b2538c2a/src/hotspot/share/runtime/nonJavaThread.cpp#L97-L102)).
Only debug code calls `Threads::print_on()` outside a safepoint if I'm not mistaken so this solution should work in the relevant cases (jcmd, SIGQUIT, ...).
Testing:
The output of a minimal example with G1 is almost identical. The order of `NonJavaThreads` can differ.
More tests (besides GHA) are pending.
-------------
Commit messages:
- Fix
Changes: https://git.openjdk.org/jdk/pull/18518/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=18518&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8329109
Stats: 69 lines in 1 file changed: 43 ins; 14 del; 12 mod
Patch: https://git.openjdk.org/jdk/pull/18518.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/18518/head:pull/18518
PR: https://git.openjdk.org/jdk/pull/18518
More information about the hotspot-runtime-dev
mailing list