RFR: 8361103: java_lang_Thread::async_get_stack_trace does not properly protect JavaThread [v2]
David Holmes
dholmes at openjdk.org
Thu Jul 10 07:48:39 UTC 2025
On Wed, 9 Jul 2025 20:35:57 GMT, Alex Menkov <amenkov at openjdk.org> wrote:
>> Actually I think we need a further check here. If we get the carrier thread directly, we have not checked that it is actually protected by the TLH - that is normally done by `cv_internal_thread_to_JavaThread` but that doesn't know about virtual threads and carriers! I need to check if we have to fix `cv_internal_thread_to_JavaThread` for the virtual thread case.
>
> Well, we don't have TLH protection for carrier (and looks like JVMTI also doesn't care about carrier protection).
> I think it may be useful to add virtual thread support to `ThreadsListHandle` (and update comments in threadSMR.hpp).
> What about:
>
> bool cv_internal_thread_to_JavaThread(jobject jthread, JavaThread ** jt_pp, oop * thread_oop_p);
>
> + bool cv_oop_to_JavaThread(oop thread_oop, JavaThread** jt_pp);
> + bool cv_thread_or_carrier_to_JavaThread(oop thread_oop, JavaThread** jt_pp, bool* is_virtual_p = nullptr);
>
> Also we need a way to check if specific vthread is mounted to JavaThread (to be checked in handshake), I think it should go to javaThread.hpp/.cpp:
>
>
> inline bool is_vthread_mounted() const;
> + inline bool is_vthread_mounted(oop vthread) const;
>
> What do you think?
> Would be nice to hear @dcubed-ojdk opinion (AFAIK he implemented threadSMR stuff)
I was thinking simply(?) to change `cv_internal_thread_to_JavaThread` so that it extracts the carrier for a vthread and checks it is within the given threads-list.
> Also we need a way to check if specific vthread is mounted to JavaThread (to be checked in handshake)
Not sure that would be of general use as the answer could change the instant you return from the operation. Explicit checks for being mounted are done within the handshake/safepoint op code as needed.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26119#discussion_r2196884985
More information about the hotspot-dev
mailing list