RFR: 8361103: java_lang_Thread::async_get_stack_trace does not properly protect JavaThread [v6]
David Holmes
dholmes at openjdk.org
Tue Aug 5 05:45:06 UTC 2025
On Wed, 30 Jul 2025 01:43:37 GMT, Alex Menkov <amenkov at openjdk.org> wrote:
>> The fix updates `java_lang_Thread::async_get_stack_trace()` (used by `java.lang.Thread.getStackTrace()` to get stack trace for platform and mounted virtual threads) to correctly use `ThreadListHandle` for thread protection.
>>
>> Testing: tier1..5
>
> Alex Menkov has updated the pull request incrementally with one additional commit since the last revision:
>
> fix broken build
src/hotspot/share/classfile/javaClasses.cpp line 1885:
> 1883: }
> 1884:
> 1885: oop java_lang_Thread::async_get_stack_trace(jobject jthread, TRAPS) {
Please add a comment describing how the method works for virtual threads, and what returning null implies.
src/hotspot/share/classfile/javaClasses.cpp line 1897:
> 1895: class GetStackTraceHandshakeClosure : public HandshakeClosure {
> 1896: public:
> 1897: const Handle _thread_oop;
Thanks for making this change! Very confusing otherwise.
src/hotspot/share/classfile/javaClasses.cpp line 1939:
> 1937: // Target thread has been unmounted.
> 1938: return;
> 1939: }
Shouldn't we set `carrier = true` if we don't return here? Or am I misunderstanding what "carrier" means here?
src/hotspot/share/classfile/javaClasses.cpp line 1941:
> 1939: bool carrier = false;
> 1940: if (java_lang_VirtualThread::is_instance(_java_thread())) {
> 1941: // if (thread->vthread() != _java_thread()) // We might be inside a System.executeOnCarrierThread
Need to check with @AlanBateman whether this check is also needed (he does both in his draft PR).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26119#discussion_r2253138892
PR Review Comment: https://git.openjdk.org/jdk/pull/26119#discussion_r2253140711
PR Review Comment: https://git.openjdk.org/jdk/pull/26119#discussion_r2253161591
PR Review Comment: https://git.openjdk.org/jdk/pull/26119#discussion_r2253160696
More information about the hotspot-dev
mailing list