RFR: 8376568: Change Thread::getStackTrace to use handshake op for all cases [v4]

Alan Bateman alanb at openjdk.org
Thu Feb 5 08:47:10 UTC 2026


On Thu, 5 Feb 2026 02:29:53 GMT, Patricio Chilano Mateo <pchilanomate at openjdk.org> wrote:

>> 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 a similar reason.

Thanks for the thorough analysis.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29461#discussion_r2767772222


More information about the core-libs-dev mailing list