On Wed, 11 Mar 2026 13:21:50 GMT, Zhengyu Gu <[email protected]> wrote:
>> Please review this change that fixes crashes by jmm_GetThreadInfo() call.
>>
>> There are several issues:
>> - ThreadIdTable::lazy_initialize() has typical double-checked locking
>> pattern without proper memory barrier, that may result in
>> uninitialized/partial initialized table to be observed by other threads.
>> Added release/acquire barrier to address this issue.
>> - Query ThreadIdTable can race add/remove thread operations. In short, the
>> thread returned from the query may be freed. Fortunately,
>> jmm_GetThreadInfo() acquires stable thread list before query, so we only
>> need to make sure that returned thread is in the list (checking
>> thread->is_exiting() does not help due to the race)
>> - I moved thread Id insertion code from ThreadSMR to Threads, to be
>> symmetric to thread Id removal code.
>>
>> Tests:
>> - [x] Tier1 on Linux and MacOSX (fastdebug)
>> (`tools/javac/annotations/typeAnnotations/IncorrectCastOffsetTest.java`
>> failure seems unrelated, it also fails in master)
>
> Zhengyu Gu has updated the pull request incrementally with one additional
> commit since the last revision:
>
> More from @dholmes-ora
Functional changes look good. Thanks
Test is a bit hard to follow but seems just to be trying to produce some
interesting thread dumps to exercise different code. I don't see how the test
terminates though??
test/hotspot/jtreg/serviceability/threads/ThreadInfoTest.java line 38:
> 36: * @bug 8323792
> 37: * @summary Make sure that jmm_GetThreadInfo() call does not crash JVM
> 38: * @library /test/lib
Please add
* @module java.management
test/hotspot/jtreg/serviceability/threads/ThreadInfoTest.java line 144:
> 142: public void run() {
> 143: boolean replacing = false;
> 144: while (true) {
What will cause this thread to terminate?
test/hotspot/jtreg/serviceability/threads/ThreadInfoTest.java line 191:
> 189:
> 190: public void run() {
> 191: while (true) {
What will cause this thread to terminate?
test/hotspot/jtreg/serviceability/threads/ThreadInfoTest.java line 214:
> 212:
> 213: public void run() {
> 214: while (true) {
What will cause this thread to terminate?
test/hotspot/jtreg/serviceability/threads/ThreadInfoTest.java line 231:
> 229: public void run() {
> 230: long i = 0;
> 231: while (true) {
What will cause this thread to terminate?
-------------
PR Review: https://git.openjdk.org/jdk/pull/30105#pullrequestreview-3932466595
PR Review Comment: https://git.openjdk.org/jdk/pull/30105#discussion_r2920931080
PR Review Comment: https://git.openjdk.org/jdk/pull/30105#discussion_r2920935768
PR Review Comment: https://git.openjdk.org/jdk/pull/30105#discussion_r2920936809
PR Review Comment: https://git.openjdk.org/jdk/pull/30105#discussion_r2920937518
PR Review Comment: https://git.openjdk.org/jdk/pull/30105#discussion_r2920938219