Details
-
Bug
-
Resolution: Fixed
-
P3
-
11, 12, 13, 14
-
b25
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8246823 | 13.0.4 | Markus Grönlund | P3 | Resolved | Fixed | b05 |
JDK-8241264 | 11.0.8 | Markus Grönlund | P3 | Resolved | Fixed | b01 |
JDK-8247420 | openjdk8u272 | Jaroslav Bachorík | P3 | Resolved | Fixed | b01 |
JDK-8247448 | openjdk8u262 | Jaroslav Bachorík | P3 | Resolved | Fixed | b07 |
Description
// Notify JVMTI agents that VM initialization is complete - nop if no agents.
4053 JvmtiExport::post_vm_initialized();
4055 JFR_ONLY(Jfr::on_vm_start();)
...
Runs into the problematic situation that an agent can initialize JFR (using the JFR default options) in Premain in response to the JVMTI VMInit event before the command-line options specified for JFR is processed and applied.
There is also a less common issue in that an agent can initialize JFR in response to the JVMTI VMStart event. An agent is allowed to invoke JNI code at this point and could attempt to create and start a recording, for example:
void JNICALL on_vm_start(jvmtiEnv *jvmti_env, JNIEnv* jni_env) {
printf("On VM Start Event - JNI is up\n");
jclass recording_clz = (*jni_env)->FindClass(jni_env, "jdk/jfr/Recording");
jmethodID init_method = (*jni_env)->GetMethodID(jni_env, recording_clz, "<init>", "()V");
jobject recording = (*jni_env)->NewObject(jni_env, recording_clz, init_method); <<-- (attempts to) initialize JFR
jmethodID start_method = (*jni_env)->GetMethodID(jni_env, recording_clz, "start", "()V");
(*jni_env)->CallVoidMethod(jni_env, recording, start_method);
}
Besides running into the issue with not using the options specified on the command-line, the attempt will fail because JVMTI has not yet entered phase JVMTI_PHASE_LIVE which is required if Retransform is to be used (JFR uses it if JVMTI is available).
Today, the start attempt continues even though the Retransform failed (JVMTI_ERROR_WRONG_PHASE). This is not correct.
A proper error message should explain that attempting to start JFR in response to JVMTI event VMStart is disallowed because the VM has not completed initialization yet. A recommendation to use JVMTI event VMInit instead of VMStart can also be printed before fail fast with vm_exit_during_initialization().
Attachments
Issue Links
- backported by
-
JDK-8241264 Invert JvmtiExport::post_vm_initialized() and Jfr:on_vm_start() start-up order for correct option parsing
- Resolved
-
JDK-8246823 Invert JvmtiExport::post_vm_initialized() and Jfr:on_vm_start() start-up order for correct option parsing
- Resolved
-
JDK-8247420 Invert JvmtiExport::post_vm_initialized() and Jfr:on_vm_start() start-up order for correct option parsing
- Resolved
-
JDK-8247448 Invert JvmtiExport::post_vm_initialized() and Jfr:on_vm_start() start-up order for correct option parsing
- Resolved
- relates to
-
JDK-8247570 Build failure with -JFR after JDK-8233197 backport
- Resolved
-
JDK-8246703 [TESTBUG] Add test for JDK-8233197
- Resolved
-
JDK-8254673 call for JvmtiExport::post_vm_start() was removed by the fix for JDK-8249158
- Resolved