From 2d65ea61d9d780b9db0c12c5487055bfe83ef52c Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 17 Jun 2026 00:33:27 +0000 Subject: [PATCH] 8383879: assert(_cur_stack_depth == num_frames) failed: cur_stack_depth out of sync _cur_stack_depth: 9 num_frames: 10 Reviewed-by: cjplummer, dcubed, sspitsyn, dholmes --- src/hotspot/share/prims/jvmtiEnvBase.cpp | 1 + src/hotspot/share/prims/jvmtiThreadState.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index 9b4ac85f220..4c9e3d67d5f 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -2312,6 +2312,7 @@ SetForceEarlyReturn::doit(Thread *target) { // Set pending step flag for this early return. // It is cleared when next step event is posted. _state->set_pending_step_for_earlyret(); + _state->invalidate_cur_stack_depth(); } void diff --git a/src/hotspot/share/prims/jvmtiThreadState.cpp b/src/hotspot/share/prims/jvmtiThreadState.cpp index 5f496bbc6d4..a1bcf3a0137 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.cpp +++ b/src/hotspot/share/prims/jvmtiThreadState.cpp @@ -409,7 +409,8 @@ int JvmtiThreadState::cur_stack_depth() { guarantee(get_thread()->is_handshake_safe_for(current), "must be current thread or direct handshake"); - if (!is_interp_only_mode() || _cur_stack_depth == UNKNOWN_STACK_DEPTH) { + if (!is_interp_only_mode() || _cur_stack_depth == UNKNOWN_STACK_DEPTH + || is_pending_step_for_earlyret() || is_pending_step_for_popframe()) { _cur_stack_depth = count_frames(); } else { #ifdef ASSERT @@ -474,7 +475,7 @@ void JvmtiThreadState::process_pending_step_for_popframe() { void JvmtiThreadState::update_for_pop_top_frame() { // remove any frame pop notification request for the top frame // in any environment - int popframe_number = cur_stack_depth(); + int popframe_number = count_frames(); { JvmtiEnvThreadStateIterator it(this); for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {