Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8295816: jdwp jck tests failing with "FATAL ERROR in native method: J…
…DWP SetTag, jvmtiError=JVMTI_ERROR_WRONG_PHASE(112)"

8295815: misc JDI tests failed with "JDWP exit error JVMTI_ERROR_WRONG_PHASE(112)"

Reviewed-by: sspitsyn, amenkov, dcubed
  • Loading branch information
plummercj committed Oct 25, 2022
1 parent e0c2930 commit fec6174
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/jdk.jdwp.agent/share/native/libjdwp/classTrack.c
Expand Up @@ -68,6 +68,21 @@ cbTrackingClassPrepare(jvmtiEnv* jvmti_env, JNIEnv *env, jthread thread, jclass
addPreparedClass(env, klass);
}

/*
* It's ok to get WRONG_PHASE errors once the vm is dead. We can just
* ignore the event in that case.
*/
static jboolean
is_wrong_phase(jvmtiError error)
{
if (error == JVMTI_ERROR_WRONG_PHASE) {
JDI_ASSERT(gdata->vmDead);
return JNI_TRUE;
}
return JNI_FALSE;
}


/*
* Add a class to the prepared class hash table.
*/
Expand All @@ -78,14 +93,20 @@ addPreparedClass(JNIEnv *env, jclass klass)

char* signature;
error = classSignature(klass, &signature, NULL);
if (is_wrong_phase(error)) {
return;
}
if (error != JVMTI_ERROR_NONE) {
EXIT_ERROR(error,"signature");
}

if (gdata && gdata->assertOn) {
if (gdata->assertOn) {
// Check if already tagged.
jlong tag;
error = JVMTI_FUNC_PTR(trackingEnv, GetTag)(trackingEnv, klass, &tag);
if (is_wrong_phase(error)) {
return;
}
if (error != JVMTI_ERROR_NONE) {
EXIT_ERROR(error, "Unable to GetTag with class trackingEnv");
}
Expand All @@ -99,6 +120,9 @@ addPreparedClass(JNIEnv *env, jclass klass)
}

error = JVMTI_FUNC_PTR(trackingEnv, SetTag)(trackingEnv, klass, ptr_to_jlong(signature));
if (is_wrong_phase(error)) {
return;
}
if (error != JVMTI_ERROR_NONE) {
jvmtiDeallocate(signature);
EXIT_ERROR(error,"SetTag");
Expand Down

1 comment on commit fec6174

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.