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

Alex Menkov amenkov at openjdk.org
Wed Jul 9 20:38:47 UTC 2025


On Tue, 8 Jul 2025 01:29:40 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Got it.
>
> 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 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)

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

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


More information about the hotspot-dev mailing list