8297170: misc JCK tests fail with "FATAL ERROR in native method: JDWP Can't disable vthread end events, jvmtiError=JVMTI_ERROR_WRONG_PHASE(112)"

Reviewed-by: amenkov, dcubed, lmesnik, sspitsyn
This commit is contained in:
Chris Plummer 2022-11-30 18:08:19 +00:00
parent c68556916a
commit 1323e98df1

View File

@ -1621,6 +1621,15 @@ eventHandler_onConnect() {
debugMonitorExit(handlerLock);
}
static jvmtiError
adjust_jvmti_error(jvmtiError error) {
// Allow WRONG_PHASE if vm is exiting.
if (error == JVMTI_ERROR_WRONG_PHASE && gdata->vmDead) {
error = JVMTI_ERROR_NONE;
}
return error;
}
void
eventHandler_reset(jbyte sessionID)
{
@ -1637,18 +1646,20 @@ eventHandler_reset(jbyte sessionID)
/* Disable vthread START and END events unless we are remembering vthreads
* when no debugger is connected. We do this because these events can
* be very noisy and hurt performance a lot.
* be very noisy and hurt performance a lot. Note the VM might be exiting,
* and we might get the VM_DEATH event while executing here, so don't
* complain about JVMTI_ERROR_WRONG_PHASE if we've already seen VM_DEATH event.
*/
if (gdata->vthreadsSupported && !gdata->rememberVThreadsWhenDisconnected) {
jvmtiError error;
error = threadControl_setEventMode(JVMTI_DISABLE,
EI_VIRTUAL_THREAD_START, NULL);
if (error != JVMTI_ERROR_NONE) {
if (adjust_jvmti_error(error) != JVMTI_ERROR_NONE) {
EXIT_ERROR(error,"Can't disable vthread start events");
}
error = threadControl_setEventMode(JVMTI_DISABLE,
EI_VIRTUAL_THREAD_END, NULL);
if (error != JVMTI_ERROR_NONE) {
if (adjust_jvmti_error(error) != JVMTI_ERROR_NONE) {
EXIT_ERROR(error,"Can't disable vthread end events");
}
}