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

Alex Menkov amenkov at openjdk.org
Fri Jul 11 00:16:39 UTC 2025


On Thu, 10 Jul 2025 23:34:50 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:

>> Alex Menkov has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   carrier in TLH
>
> 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?

Yes, that's right.
vthread can be unmounted at any moment. So it's caller responsibility to check is vthread is still mounted to the same carrier thread in handshake/VMOp (see comment about virtul threads in the threadSMR.hpp)
`VirtualThread.asyncGetStackTrace` retries to get stack trace in the case

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

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


More information about the hotspot-dev mailing list