On Mon, 30 Nov 2026 13:58:37 GMT, Roman Kennke <[email protected]> wrote:

> For a negative `start_depth`, `GetStackTrace` walks to the bottom of the 
> stack, then resumes from an earlier `javaVFrame`. The `RegisterMap` copies 
> share a mutable stack-chunk handle. By the time the walk resumes from
>  the saved frame, that handle may point to a different chunk or have been 
> cleared. This can cause HotSpot to walk a heap-backed frame as though it were 
> on the native stack.
> 
> Before resuming the walk, compare the map’s current chunk with the chunk 
> saved by the frame. If they differ, give the map a fresh mutable handle 
> initialized to the saved chunk, leaving the chunk index and
>  register state unchanged. This preserves the existing walk algorithm: it 
> does not add a frame-counting pass or allocate a new handle for stacks that 
> never enter a chunk.
> 
> The regression test compares negative-depth traces with the corresponding 
> slices of the full trace for both an unmounted virtual thread and a mounted 
> virtual thread with frames still in a stack chunk. It also
>  checks truncation and out-of-range depths.
> 
> Testing: All 28 JVMTI thread tests passed on Linux x86-64 fastdebug. The new 
> test also passed with `-Xint`, `-Xcomp`, ZGC, Shenandoah, and 
> `-XX:-UseContinuationFastPath`. A separate check verified all 618 valid
>  negative depths on a virtual thread with two non-empty stack chunks under 
> both `-Xint` and `-Xcomp`.
> 
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Thank you for fixing this. It looks good in general. I still need to review new 
test.

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

PR Review: https://git.openjdk.org/jdk/pull/34123#pullrequestreview-6181782525

Reply via email to