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

David Holmes dholmes at openjdk.org
Tue Jul 8 01:55:38 UTC 2025


On Mon, 7 Jul 2025 19:36:22 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:
> 
>   removed comment

Revoking my approval as there may be further issues.

I'm also unclear if this code in the handshake is sufficient for dealing with the case where we have a mounted virtual thread initially, but it is unmounted before the handshake gets to execute:

    if (java_lang_VirtualThread::is_instance(_java_thread())) {
        // if (thread->vthread() != _java_thread()) // We might be inside a System.executeOnCarrierThread
        const ContinuationEntry* ce = thread->vthread_continuation();
        if (ce == nullptr || ce->cont_oop(thread) != java_lang_VirtualThread::continuation(_java_thread())) {
          return; // not mounted
        }
      }

The commented line seems an inaccurate characterization as we could be executing a completely different virtual thread on this carrier now - which is not related to `executeOnCarrierThread`.

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

Changes requested by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26119#pullrequestreview-2995739261
PR Comment: https://git.openjdk.org/jdk/pull/26119#issuecomment-3047089860


More information about the hotspot-dev mailing list