On Wed, 18 Feb 2026 19:19:23 GMT, Serguei Spitsyn <[email protected]> wrote:

>> The `interp-only` mechanism is based on the `JavaThread` objects. Carrier 
>> and virtual threads can temporary share the same `JavaThread`. The 
>> `java_thread->jvmti_thread_state()` is re-linked to a virtual thread at 
>> `mount` and to the carrier thread at `unmount`. The `JvmtiThreadState` has a 
>> back link to the `JavaThread` which is also set for virtual thread at a 
>> `mount` and carrier thread at an `unmount`. Just one of these two links at 
>> the same time is set to the `JavaThread`, the other one has to be set to 
>> `nullptr`. The `interp-only` mechanism needs this invariant.
>> However, there is a corner case when this invariant is broken. It happens 
>> when the `JvmtiThreadState` for carrier thread has just been created. In 
>> such case, the link to `JavaThread` is always `non-nullptr` even though a 
>> virtual thread is currently mounted on a carrier thread. This simple update 
>> fixes the issue in the  `JvmtiThreadState` ctor.
>> 
>> Also, this update the includes the `interp_only` implementation 
>> simplifications and more asserts are added to relevant places. One of the 
>> simplification is a removal of the field `JvmtiThreadState::_thread_saved`.
>> 
>> Testing:
>>  - TBD: Mach5 tiers 1-6
>
> Serguei Spitsyn has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   review: moved comment clarifying _thread from its init to definition

Overall fix looks good, small clean-up related comment only

src/hotspot/share/prims/jvmtiThreadState.cpp line 483:

> 481:     invalidate_cur_stack_depth();
> 482:   } else {
> 483:     assert(!is_enabled(JVMTI_EVENT_FRAME_POP), "Must have no framepops 
> set");

This change is not related to the the bug, better to fix separately.

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

Changes requested by lmesnik (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29436#pullrequestreview-3835072216
PR Review Comment: https://git.openjdk.org/jdk/pull/29436#discussion_r2835859114

Reply via email to