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
This commit is contained in:
Daniel D. Daugherty 2023-12-04 20:53:46 +00:00
parent bd04f91e91
commit 30b5d42735

View File

@ -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;
}