Skip to content


Browse files Browse the repository at this point in the history
8282200: ShouldNotReachHere() reached by AsyncGetCallTrace after JDK-…

Reviewed-by: dholmes, mdoerr, kevinw
  • Loading branch information
parttimenerd authored and TheRealMDoerr committed Feb 24, 2022
1 parent f4486a1 commit 231e48f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/hotspot/share/prims/forte.cpp
Expand Up @@ -562,12 +562,11 @@ static void forte_fill_call_trace_given_top(JavaThread* thd,
extern "C" {
void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {

JavaThread* thread;

if (trace->env_id == NULL ||
(thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL ||
thread->is_exiting()) {

(thread = JavaThread::thread_from_jni_environment(trace->env_id))->is_exiting()) {
// bad env_id, thread has exited or thread is exiting
trace->num_frames = ticks_thread_exit; // -8
Expand Down
7 changes: 4 additions & 3 deletions src/hotspot/share/runtime/thread.hpp
Expand Up @@ -1323,14 +1323,15 @@ class JavaThread: public Thread {
// external JNI entry points where the JNIEnv is passed into the VM.
static JavaThread* thread_from_jni_environment(JNIEnv* env) {
JavaThread* current = (JavaThread*)((intptr_t)env - in_bytes(jni_environment_offset()));
// We can't get here in a thread that has completed its execution and so
// "is_terminated", but a thread is also considered terminated if the VM
// We can't normally get here in a thread that has completed its
// execution and so "is_terminated", except when the call is from
// AsyncGetCallTrace, which can be triggered by a signal at any point in
// a thread's lifecycle. A thread is also considered terminated if the VM
// has exited, so we have to check this and block in case this is a daemon
// thread returning to the VM (the JNI DirectBuffer entry points rely on
// this).
if (current->is_terminated()) {
return current;
Expand Down

1 comment on commit 231e48f

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.