JDK-8362203 : assert(state == nullptr || state->get_thread_oop() != nullptr) failed: incomplete state
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 26
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-07-14
  • Updated: 2025-07-25
  • Resolved: 2025-07-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26 b08Fixed
Related Reports
Relates :  
Description
#  Internal Error (/Users/lmesnik/ws/jdk/post_early/open/src/hotspot/share/prims/jvmtiThreadState.inline.hpp:98), pid=74504, tid=8963
#  assert(state == nullptr || state->get_thread_oop() != nullptr) failed: incomplete state
#
# JRE version: OpenJDK Runtime Environment (26.0) (fastdebug build 26-internal-adhoc.lmesnik.open)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 26-internal-adhoc.lmesnik.open, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)

happens in the 

Current thread (0x0000000125021e10):  JavaThread "main"             [_thread_in_vm, id=8963, stack(0x000000016d84c000,0x000000016da4f000) (2060K)] _threads_hazard_ptr=0x000060000297fe10, _nested_threads_hazard_ptr_cnt=0

Stack: [0x000000016d84c000,0x000000016da4f000],  sp=0x000000016da4dd30,  free space=2055k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.dylib+0x13fc3e4]  VMError::report(outputStream*, bool)+0x1b00  (jvmtiThreadState.inline.hpp:98)
V  [libjvm.dylib+0x13ffc84]  VMError::report_and_die(int, char const*, char const*, char*, Thread*, unsigned char*, void const*, void const*, char const*, int, unsigned long)+0x55c
V  [libjvm.dylib+0x5c7278]  print_error_for_unit_test(char const*, char const*, char*)+0x0
V  [libjvm.dylib+0xbad064]  JvmtiThreadState::state_for_while_locked(JavaThread*, oop)+0x488
V  [libjvm.dylib+0xbac654]  JvmtiThreadState::state_for(JavaThread*, Handle)+0x250
V  [libjvm.dylib+0xc11554]  JvmtiEnv::GetThreadLocalStorage(_jobject*, void**)+0x2e0
C  [libjdwp.dylib+0x22408]  findThread+0x84
C  [libjdwp.dylib+0x21b64]  insertThread+0x38
C  [libjdwp.dylib+0x21a28]  threadControl_onHook+0x78
C  [libjdwp.dylib+0x14c4c]  eventHandler_initialize+0x658
C  [libjdwp.dylib+0x10b74]  initialize+0x1c8
C  [libjdwp.dylib+0xfc44]  cbEarlyVMInit+0x80
V  [libjvm.dylib+0xc3cf5c]  JvmtiExport::post_vm_initialized()+0x374
V  [libjvm.dylib+0x1351500]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x900
V  [libjvm.dylib+0xa20190]  JNI_CreateJavaVM+0x7c
C  [libjli.dylib+0xa3d0]  JavaMain+0x100
C  [libjli.dylib+0xd52c]  ThreadJavaMain+0xc
C  [libsystem_pthread.dylib+0x6c0c]  _pthread_start+0x88
Lock stack of current Java thread (top to bottom):
Comments
Changeset: bd55d7a4 Branch: master Author: Leonid Mesnik <lmesnik@openjdk.org> Date: 2025-07-17 16:25:40 +0000 URL: https://git.openjdk.org/jdk/commit/bd55d7a49514da9fa4de0d4a372956e21deab4d2
17-07-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/26303 Date: 2025-07-14 23:42:03 +0000
15-07-2025

The problem happens if post_early_vm_start is triggered. jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { ..... // Notify JVMTI agents that VM has started (JNI is up) - nop if no agents. JvmtiExport::post_early_vm_start(); ^^^ this method tries to initialize jvmti thread state for main // Launch -Xrun agents early if EagerXrunInit is set if (EagerXrunInit) { JvmtiAgentList::load_xrun_agents(); } initialize_java_lang_classes(main_thread, CHECK_JNI_ERR); ^^^ the initial classes become available only at this point. .. } so might have the jvmti state without thread_oop, and hit assertion.
14-07-2025

The issue happens with following modification which should be added as a regression test case: --- a/test/hotspot/jtreg/serviceability/jvmti/StartPhase/AllowedFunctions/AllowedFunctions.java +++ b/test/hotspot/jtreg/serviceability/jvmti/StartPhase/AllowedFunctions/AllowedFunctions.java @@ -29,6 +29,7 @@ * @requires vm.jvmti * @run main/othervm/native -agentlib:AllowedFunctions AllowedFunctions * @run main/othervm/native -agentlib:AllowedFunctions=with_early_vmstart AllowedFunctions + * @run main/othervm/native -agentlib:AllowedFunctions=with_early_vmstart -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n AllowedFunctions */ public class AllowedFunctions {
14-07-2025