8248379: Handshake closures for JVMTI monitor functions lack of some validations

Reviewed-by: sspitsyn, dholmes
This commit is contained in:
Yasumasa Suenaga 2020-06-29 13:35:45 +09:00
parent 9d6797019b
commit 5ad963cf61
3 changed files with 21 additions and 9 deletions

@ -1213,8 +1213,8 @@ JvmtiEnv::GetOwnedMonitorInfo(JavaThread* java_thread, jint* owned_monitor_count
} else {
// get owned monitors info with handshake
GetOwnedMonitorInfoClosure op(calling_thread, this, owned_monitors_list);
Handshake::execute_direct(&op, java_thread);
err = op.result();
bool executed = Handshake::execute_direct(&op, java_thread);
err = executed ? op.result() : JVMTI_ERROR_THREAD_NOT_ALIVE;
}
jint owned_monitor_count = owned_monitors_list->length();
if (err == JVMTI_ERROR_NONE) {
@ -1258,8 +1258,8 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i
} else {
// get owned monitors info with handshake
GetOwnedMonitorInfoClosure op(calling_thread, this, owned_monitors_list);
Handshake::execute_direct(&op, java_thread);
err = op.result();
bool executed = Handshake::execute_direct(&op, java_thread);
err = executed ? op.result() : JVMTI_ERROR_THREAD_NOT_ALIVE;
}
jint owned_monitor_count = owned_monitors_list->length();
@ -1302,8 +1302,8 @@ JvmtiEnv::GetCurrentContendedMonitor(JavaThread* java_thread, jobject* monitor_p
} else {
// get contended monitor information with handshake
GetCurrentContendedMonitorClosure op(calling_thread, this, monitor_ptr);
Handshake::execute_direct(&op, java_thread);
err = op.result();
bool executed = Handshake::execute_direct(&op, java_thread);
err = executed ? op.result() : JVMTI_ERROR_THREAD_NOT_ALIVE;
}
return err;
} /* end GetCurrentContendedMonitor */

@ -1507,12 +1507,24 @@ VM_SetFramePop::doit() {
void
GetOwnedMonitorInfoClosure::do_thread(Thread *target) {
_result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, (JavaThread *)target, _owned_monitors_list);
assert(target->is_Java_thread(), "just checking");
JavaThread *jt = (JavaThread *)target;
if (!jt->is_exiting() && (jt->threadObj() != NULL)) {
_result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread,
jt,
_owned_monitors_list);
}
}
void
GetCurrentContendedMonitorClosure::do_thread(Thread *target) {
_result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread, (JavaThread *)target, _owned_monitor_ptr);
assert(target->is_Java_thread(), "just checking");
JavaThread *jt = (JavaThread *)target;
if (!jt->is_exiting() && (jt->threadObj() != NULL)) {
_result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread,
jt,
_owned_monitor_ptr);
}
}
void

@ -387,7 +387,7 @@ public:
: HandshakeClosure("GetOwnedMonitorInfo"),
_calling_thread(calling_thread),
_env(env),
_result(JVMTI_ERROR_NONE),
_result(JVMTI_ERROR_THREAD_NOT_ALIVE),
_owned_monitors_list(owned_monitor_list) {}
jvmtiError result() { return _result; }
void do_thread(Thread *target);