Skip to content

Commit 25c9689

Browse files
authored
Merge pull request #22393 from babsingh/main12_v054
(0.54) Adjust maxFrames in jvmtiInternalGetStackTrace for skipped frames
2 parents 925f855 + 299aec2 commit 25c9689

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

runtime/jvmti/jvmtiStackFrame.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,24 @@ jvmtiInternalGetStackTrace(
868868
}
869869
walkState.skipCount = framesWalked + start_depth;
870870
}
871+
871872
walkState.maxFrames = max_frame_count;
873+
874+
#if JAVA_SPEC_VERSION >= 20
875+
/* Adjusts the second‑pass stack walk limit (maxFrames) to include the
876+
* number of frames skipped in the first pass (userData1).
877+
*
878+
* When the first pass walks more frames than the original max_frame_count,
879+
* the skipped frame count is added to the limit so that, after skipping,
880+
* up to max_frame_count frames can still be returned to the caller.
881+
*/
882+
if (walkState.framesWalked > max_frame_count) {
883+
UDATA skippedFrames = (UDATA)walkState.userData1;
884+
Assert_JVMTI_true(skippedFrames <= (UDATA_MAX - max_frame_count));
885+
walkState.maxFrames += skippedFrames;
886+
}
887+
#endif /* JAVA_SPEC_VERSION >= 20 */
888+
872889
walkState.flags = J9_STACKWALK_INCLUDE_NATIVES | J9_STACKWALK_VISIBLE_ONLY
873890
| J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET | J9_STACKWALK_COUNT_SPECIFIED
874891
| J9_STACKWALK_ITERATE_FRAMES;

0 commit comments

Comments
 (0)