Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8248379: Handshake closures for JVMTI monitor functions lack of some …
…validations

Reviewed-by: sspitsyn, dholmes
  • Loading branch information
YaSuenag committed Jun 29, 2020
1 parent 9d67970 commit 5ad963cf6135ed7491b22109d72228abfee41dce
Show file tree
Hide file tree
Showing 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 @@ class GetOwnedMonitorInfoClosure : public HandshakeClosure {
: 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);

0 comments on commit 5ad963c

Please sign in to comment.