-
Bug
-
Resolution: Unresolved
-
P3
-
None
-
21.0.8, 25, 26
An attempt to attach a Java agent or JVM TI agent shortly after JVM startup (before it is fully initialized) results in a JVM crash.
fastdebug JVM fails on the following assertion:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/andrei/jdk/src/hotspot/share/prims/jvmtiAgent.cpp:502), pid=2790, tid=2802
# assert(JvmtiEnvBase::get_phase() == JVMTI_PHASE_LIVE) failed: not in live phase!
#
# JRE version: OpenJDK Runtime Environment (25.0) (fastdebug build 25-internal-adhoc.andrei.jdk)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 25-internal-adhoc.andrei.jdk, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x12e68d7] JvmtiAgent::load(outputStream*)+0x777
#
# Core dump will be written. Default location: Core dumps may be processed with "/wsl-capture-crash %t %E %p %s" (or dumping to /mnt/andrei/c/core.2790)
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x000079537821fc60): JavaThread "Attach Listener" daemon [_thread_in_vm, id=2802, stack(0x000079536420c000,0x000079536430c000) (1024K)]
Stack: [0x000079536420c000,0x000079536430c000], sp=0x000079536430a890, free space=1018k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x12e68d7] JvmtiAgent::load(outputStream*)+0x777 (jvmtiAgent.cpp:502)
V [libjvm.so+0x12e8286] JvmtiAgentList::load_agent(char const*, bool, char const*, outputStream*)+0x56 (jvmtiAgentList.cpp:205)
V [libjvm.so+0xcd4b30] DCmd::Executor::execute(DCmd*, JavaThread*)+0x20 (diagnosticFramework.cpp:421)
V [libjvm.so+0x7d9858] jcmd(AttachOperation*, attachStream*)::Executor::execute(DCmd*, JavaThread*)+0x38 (attachListener.cpp:394)
V [libjvm.so+0xcd850e] DCmd::Executor::parse_and_execute(char const*, char, JavaThread*)+0x44e (diagnosticFramework.cpp:414)
V [libjvm.so+0x7d7ec8] jcmd(AttachOperation*, attachStream*)+0x88 (attachListener.cpp:398)
V [libjvm.so+0x7da684] AttachListenerThread::thread_entry(JavaThread*, JavaThread*)+0x314 (attachListener.cpp:639)
V [libjvm.so+0x1080f7e] JavaThread::thread_main_inner()+0xee (javaThread.cpp:772)
V [libjvm.so+0x1be9c7e] Thread::call_run()+0xbe (thread.cpp:243)
V [libjvm.so+0x16e9c2b] thread_native_entry(Thread*)+0x12b (os_linux.cpp:868)
A real-life use case is having a script that launches a Java program and then immediately starts a profiler on it.
The problem can be reproduced with the attached program: earlyattach.c
Compile: gcc -fPIC -shared -oearlyattach.so earlyattach.c
Run: java -XX:+StartAttachListener -agentpath:./earlyattach.so -version
fastdebug JVM fails on the following assertion:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/home/andrei/jdk/src/hotspot/share/prims/jvmtiAgent.cpp:502), pid=2790, tid=2802
# assert(JvmtiEnvBase::get_phase() == JVMTI_PHASE_LIVE) failed: not in live phase!
#
# JRE version: OpenJDK Runtime Environment (25.0) (fastdebug build 25-internal-adhoc.andrei.jdk)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 25-internal-adhoc.andrei.jdk, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x12e68d7] JvmtiAgent::load(outputStream*)+0x777
#
# Core dump will be written. Default location: Core dumps may be processed with "/wsl-capture-crash %t %E %p %s" (or dumping to /mnt/andrei/c/core.2790)
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x000079537821fc60): JavaThread "Attach Listener" daemon [_thread_in_vm, id=2802, stack(0x000079536420c000,0x000079536430c000) (1024K)]
Stack: [0x000079536420c000,0x000079536430c000], sp=0x000079536430a890, free space=1018k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x12e68d7] JvmtiAgent::load(outputStream*)+0x777 (jvmtiAgent.cpp:502)
V [libjvm.so+0x12e8286] JvmtiAgentList::load_agent(char const*, bool, char const*, outputStream*)+0x56 (jvmtiAgentList.cpp:205)
V [libjvm.so+0xcd4b30] DCmd::Executor::execute(DCmd*, JavaThread*)+0x20 (diagnosticFramework.cpp:421)
V [libjvm.so+0x7d9858] jcmd(AttachOperation*, attachStream*)::Executor::execute(DCmd*, JavaThread*)+0x38 (attachListener.cpp:394)
V [libjvm.so+0xcd850e] DCmd::Executor::parse_and_execute(char const*, char, JavaThread*)+0x44e (diagnosticFramework.cpp:414)
V [libjvm.so+0x7d7ec8] jcmd(AttachOperation*, attachStream*)+0x88 (attachListener.cpp:398)
V [libjvm.so+0x7da684] AttachListenerThread::thread_entry(JavaThread*, JavaThread*)+0x314 (attachListener.cpp:639)
V [libjvm.so+0x1080f7e] JavaThread::thread_main_inner()+0xee (javaThread.cpp:772)
V [libjvm.so+0x1be9c7e] Thread::call_run()+0xbe (thread.cpp:243)
V [libjvm.so+0x16e9c2b] thread_native_entry(Thread*)+0x12b (os_linux.cpp:868)
A real-life use case is having a script that launches a Java program and then immediately starts a profiler on it.
The problem can be reproduced with the attached program: earlyattach.c
Compile: gcc -fPIC -shared -oearlyattach.so earlyattach.c
Run: java -XX:+StartAttachListener -agentpath:./earlyattach.so -version