RFR: 8359472: JVM crashes when attaching a dynamic agent before JVMTI_PHASE_LIVE [v2]
David Holmes
dholmes at openjdk.org
Thu Oct 16 08:32:17 UTC 2025
On Tue, 14 Oct 2025 08:17:19 GMT, Francesco Andreuzzi <fandreuzzi at openjdk.org> wrote:
>> In this PR I add a check to prevent debug builds to crash when an agent tries to attach while the JVM is not in live phase.
>>
>> Passes tier1 and tier2 (fastdebug).
>
> Francesco Andreuzzi has updated the pull request incrementally with one additional commit since the last revision:
>
> summary
Generally looks good. Not 100% sure on the test structure but serviceability folk can chime in there if needed.
Suggestion:
diff --git a/src/jdk.jcmd/share/man/jcmd.md b/src/jdk.jcmd/share/man/jcmd.md
index 4e67e7a4502..69784050984 100644
--- a/src/jdk.jcmd/share/man/jcmd.md
+++ b/src/jdk.jcmd/share/man/jcmd.md
@@ -551,7 +551,7 @@ ## Commands for jcmd
events, use `JFR.view all-events`.
`JVMTI.agent_load` [*arguments*]
-: Loads JVMTI native agent.
+: Loads JVMTI native agent. (Live phase only)
Impact: Low
src/hotspot/share/prims/jvmtiAgentList.cpp line 200:
> 198: const char* options, outputStream* st) {
> 199: if (JvmtiEnvBase::get_phase() != JVMTI_PHASE_LIVE) {
> 200: st->print_cr("Not in live phase");
Suggestion:
st->print_cr("Dynamic agent loading is only permitted in the live phase");
test/hotspot/jtreg/serviceability/EarlyDynamicLoad/TestEarlyDynamicLoadJcmd.java line 45:
> 43: "-agentpath:" + Utils.TEST_NATIVE_PATH + File.separator + System.mapLibraryName("EarlyDynamicLoad"),
> 44: "-version");
> 45: pb.environment().put("MODE", "jcmd");
This env-var seems unused
test/hotspot/jtreg/serviceability/EarlyDynamicLoad/TestEarlyDynamicLoadJcmd.java line 50:
> 48:
> 49: OutputAnalyzer output = new OutputAnalyzer(pb.start());
> 50: output.shouldHaveExitValue(0);
Yes but more importantly we should be checking for the "not in live phase" error message.
-------------
Changes requested by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/27766#pullrequestreview-3343557488
PR Review Comment: https://git.openjdk.org/jdk/pull/27766#discussion_r2434967688
PR Review Comment: https://git.openjdk.org/jdk/pull/27766#discussion_r2435031512
PR Review Comment: https://git.openjdk.org/jdk/pull/27766#discussion_r2435035321
More information about the serviceability-dev
mailing list