RFR: 8361103: java_lang_Thread::async_get_stack_trace does not properly protect JavaThread [v4]

David Holmes dholmes at openjdk.org
Fri Jul 11 05:09:40 UTC 2025


On Fri, 11 Jul 2025 02:09:20 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> @dcubed-ojdk No you are not missing anything, the vthread could become unmounted. It is up to the subsequent handshake code to re-check that (as briefly discussed above).
>
> Except I'm now discovering that can't work other than to abandon the virtual thread in question if you found the carrier has changed, otherwise you are in a handshake with the wrong carrier and so can't grab the stack - but that means you need to retry for this virtual thread.

I see the current code just produces an empty stack trace if the virtual thread is found to have switched carriers. This seems wrong. We should be "pinning" the virtual thread whilst we try to get its stacktrace, such that it is unmounted or else mounted and fixed to a carrier. Other thread walking code uses the JvmtiVTMSTransitionDisabler to try and achieve this.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26119#discussion_r2199604664


More information about the hotspot-dev mailing list