--- old/src/hotspot/share/prims/jvmtiThreadState.cpp 2020-08-24 11:22:03.581965994 +0900 +++ new/src/hotspot/share/prims/jvmtiThreadState.cpp 2020-08-24 11:22:03.501963679 +0900 @@ -272,9 +272,11 @@ } int JvmtiThreadState::cur_stack_depth() { - guarantee(SafepointSynchronize::is_at_safepoint() || - (JavaThread *)Thread::current() == get_thread(), - "must be current thread or at safepoint"); +#ifdef ASSERT + Thread *current = Thread::current(); +#endif + guarantee(current == get_thread() || current == get_thread()->active_handshaker(), + "must be current thread or direct handshake"); if (!is_interp_only_mode() || _cur_stack_depth == UNKNOWN_STACK_DEPTH) { _cur_stack_depth = count_frames();