From 30b5d427350d03ec8b9eb39fbf06fbd1b1f66cd8 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Mon, 4 Dec 2023 20:53:46 +0000 Subject: [PATCH] 8321069: JvmtiThreadState::state_for_while_locked() returns nullptr for an attached JNI thread with a java.lang.Thread object after JDK-8319935 Reviewed-by: dholmes, jiangli, sspitsyn --- src/hotspot/share/prims/jvmtiThreadState.inline.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/prims/jvmtiThreadState.inline.hpp b/src/hotspot/share/prims/jvmtiThreadState.inline.hpp index 0df26a1b1c5..a8f00fdce32 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.inline.hpp +++ b/src/hotspot/share/prims/jvmtiThreadState.inline.hpp @@ -82,10 +82,11 @@ inline JvmtiThreadState* JvmtiThreadState::state_for_while_locked(JavaThread *th JvmtiThreadState *state = thread == nullptr ? nullptr : thread->jvmti_thread_state(); if (state == nullptr && thread != nullptr && - (thread->is_exiting() || thread->is_attaching_via_jni())) { - // Don't add a JvmtiThreadState to a thread that is exiting or is attaching. - // When a thread is attaching, it may not have a Java level thread object - // created yet. + (thread->is_exiting() || + (thread->threadObj() == nullptr && thread->is_attaching_via_jni()) + )) { + // Don't add a JvmtiThreadState to a thread that is exiting, or is attaching + // and does not yet have a Java level thread object allocated. return nullptr; }