Skip to content

Commit 94811c0

Browse files
author
Serguei Spitsyn
committed
8286960: Test serviceability/jvmti/vthread/SuspendResume2 crashed: missing ThreadsListHandle in calling context
Reviewed-by: dholmes, pchilanomate, amenkov
1 parent 3d6d7b7 commit 94811c0

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/hotspot/share/prims/jvmtiEnv.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -929,13 +929,13 @@ JvmtiEnv::GetAllThreads(jint* threads_count_ptr, jthread** threads_ptr) {
929929
jvmtiError
930930
JvmtiEnv::SuspendThread(jthread thread) {
931931
JavaThread* current = JavaThread::current();
932-
ThreadsListHandle tlh(current);
933932

934933
jvmtiError err;
935934
JavaThread* java_thread = NULL;
936935
oop thread_oop = NULL;
937936
{
938937
JvmtiVTMSTransitionDisabler disabler(true);
938+
ThreadsListHandle tlh(current);
939939

940940
err = get_threadOop_and_JavaThread(tlh.list(), thread, &java_thread, &thread_oop);
941941
if (err != JVMTI_ERROR_NONE) {
@@ -960,13 +960,13 @@ JvmtiEnv::SuspendThread(jthread thread) {
960960
jvmtiError
961961
JvmtiEnv::SuspendThreadList(jint request_count, const jthread* request_list, jvmtiError* results) {
962962
JavaThread* current = JavaThread::current();
963-
ThreadsListHandle tlh(current);
964963
HandleMark hm(current);
965964
Handle self_tobj = Handle(current, NULL);
966965
int self_idx = -1;
967966

968967
{
969968
JvmtiVTMSTransitionDisabler disabler(true);
969+
ThreadsListHandle tlh(current);
970970

971971
for (int i = 0; i < request_count; i++) {
972972
JavaThread *java_thread = NULL;
@@ -1013,19 +1013,20 @@ JvmtiEnv::SuspendAllVirtualThreads(jint except_count, const jthread* except_list
10131013
return JVMTI_ERROR_NONE; // Nothing to do when there are no virtual threads;
10141014
}
10151015
JavaThread* current = JavaThread::current();
1016-
ThreadsListHandle tlh(current);
1017-
jvmtiError err = JvmtiEnvBase::check_thread_list(except_count, except_list);
1018-
if (err != JVMTI_ERROR_NONE) {
1019-
return err;
1020-
}
10211016
HandleMark hm(current);
10221017
Handle self_tobj = Handle(current, NULL);
10231018

10241019
{
10251020
ResourceMark rm(current);
10261021
JvmtiVTMSTransitionDisabler disabler(true);
1022+
ThreadsListHandle tlh(current);
10271023
GrowableArray<jthread>* elist = new GrowableArray<jthread>(except_count);
10281024

1025+
jvmtiError err = JvmtiEnvBase::check_thread_list(except_count, except_list);
1026+
if (err != JVMTI_ERROR_NONE) {
1027+
return err;
1028+
}
1029+
10291030
// Collect threads from except_list for which resumed status must be restored.
10301031
for (int idx = 0; idx < except_count; idx++) {
10311032
jthread thread = except_list[idx];

src/hotspot/share/runtime/thread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,8 +1778,8 @@ bool JavaThread::java_suspend() {
17781778
assert(!is_VTMS_transition_disabler(), "no suspend allowed for VTMS transition disablers");
17791779
#endif
17801780

1781-
guarantee(Thread::is_JavaThread_protected_by_TLH(/* target */ this),
1782-
"missing ThreadsListHandle in calling context.");
1781+
guarantee(Thread::is_JavaThread_protected(/* target */ this),
1782+
"target JavaThread is not protected in calling context.");
17831783
return this->handshake_state()->suspend();
17841784
}
17851785

0 commit comments

Comments
 (0)