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

David Holmes dholmes at openjdk.org
Fri Jan 30 04:47:50 UTC 2026


On Thu, 29 Jan 2026 09:12:21 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> src/hotspot/share/services/threadService.cpp line 1479:
>> 
>>> 1477:   if (cl._thread_status == JavaThreadStatus::NEW || cl._thread_status == JavaThreadStatus::TERMINATED) {
>>> 1478:     return nullptr;
>>> 1479:   }
>> 
>> It is not obvious to me why this is only a possibility now?
>
> ThreadSnapshot.of(Thread) may be invoked with a platform or virtual Thread in any state. It could sample the thread state before calling ThreadSnapshotFactory::get_thread_snapshot. That would allow it to filter out unstarted/NEW threads. It could also filter terminated threads but that would be racy and get_thread_snapshot would still need to handle terminated threads.
> 
> For platform threads, get_thread_snapshot will bail out early if there is no JavaThread. So the effect of the above is to have virtual threads also be filtered out.

Still not clear to me why any new thread is not already filtered out long before now; nor why we have not needed this in the past.

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

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


More information about the core-libs-dev mailing list