RFR: 8361103: java_lang_Thread::async_get_stack_trace does not properly protect JavaThread [v4]
David Holmes
dholmes at openjdk.org
Fri Jul 11 02:11:51 UTC 2025
On Fri, 11 Jul 2025 00:19:47 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> src/hotspot/share/runtime/threadSMR.cpp line 797:
>>
>>> 795: // return JavaThread for the carrier thread; if the thread is unmounted
>>> 796: // or use_carrier is false, return false.
>>> 797: //
>>
>> Right after the check on L827 below, what prevents the vthread from being unmounted?
>>
>> So we fetch the JavaThread* on L833 and then verify that it is protected by the TLH
>> which is good, but that does not prevent the vthread from being unmounted by the
>> time that we return the JavaThread* on L853 below.
>>
>> Am I missing something?
>
> @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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26119#discussion_r2199302545
More information about the hotspot-dev
mailing list