RFR: 8376568: Change Thread::getStackTrace to use handshake op for all cases [v4]
Patricio Chilano Mateo
pchilanomate at openjdk.org
Thu Feb 5 02:32:40 UTC 2026
On Wed, 4 Feb 2026 23:17:46 GMT, Patricio Chilano Mateo <pchilanomate at openjdk.org> wrote:
>> Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
>>
>> - Merge branch 'master' into JDK-8376568
>> - Merge branch 'master' into JDK-8376568
>> - Review feedback
>> - Improve asserts
>> - Cleanup
>> - Merge branch 'master' into Thread.getStackTrace
>> - Initial commit
>
> src/java.base/share/classes/jdk/internal/vm/ThreadSnapshot.java line 63:
>
>> 61: */
>> 62: static ThreadSnapshot of(Thread thread) {
>> 63: ThreadSnapshot snapshot = thread.isAlive() ? create(thread) : null;
>
> Looking at the implementation of `Thread.isAlive` for platform threads I'm confused now. It checks `eetop != 0`, but we set it [here](https://github.com/openjdk/jdk/blob/949370ab0e701cfcc68cb84dd0f91e5db41f4f45/src/hotspot/share/runtime/javaThread.cpp#L1732), before we change the state to RUNNABLE [here](https://github.com/openjdk/jdk/blob/949370ab0e701cfcc68cb84dd0f91e5db41f4f45/src/hotspot/share/runtime/thread.cpp#L408). So I'm wondering if we could hit the assert added in the last update in `ThreadSnapshotFactory::get_thread_snapshot`.
Never mind, the `GetThreadSnapshotHandshakeClosure` handshake will not procede until the thread is started and becomes safepoint safe, which happens after the state is set to RUNNABLE. The attached case is also fine for the same reason.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29461#discussion_r2766777490
More information about the core-libs-dev
mailing list