Skip to content

Commit 4dd316b

Browse files
committed
8307156: native_thread not protected by TLH
Reviewed-by: phh, mgronlun Backport-of: 0c6529d2d38a668f74936cca7803ca9de1a05d49
1 parent 295cf44 commit 4dd316b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/hotspot/share/jfr/jni/jfrJavaSupport.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -726,20 +726,21 @@ static bool check_exclusion_state_on_thread_start(JavaThread* jt) {
726726
return true;
727727
}
728728

729-
static JavaThread* get_native(jobject thread) {
730-
ThreadsListHandle tlh;
729+
static JavaThread* get_native(ThreadsListHandle& tlh, jobject thread) {
731730
JavaThread* native_thread = NULL;
732731
(void)tlh.cv_internal_thread_to_JavaThread(thread, &native_thread, NULL);
733732
return native_thread;
734733
}
735734

736735
jlong JfrJavaSupport::jfr_thread_id(jobject thread) {
737-
JavaThread* native_thread = get_native(thread);
736+
ThreadsListHandle tlh;
737+
JavaThread* native_thread = get_native(tlh, thread);
738738
return native_thread != NULL ? JFR_THREAD_ID(native_thread) : 0;
739739
}
740740

741741
void JfrJavaSupport::exclude(jobject thread) {
742-
JavaThread* native_thread = get_native(thread);
742+
ThreadsListHandle tlh;
743+
JavaThread* native_thread = get_native(tlh, thread);
743744
if (native_thread != NULL) {
744745
JfrThreadLocal::exclude(native_thread);
745746
} else {
@@ -749,7 +750,8 @@ void JfrJavaSupport::exclude(jobject thread) {
749750
}
750751

751752
void JfrJavaSupport::include(jobject thread) {
752-
JavaThread* native_thread = get_native(thread);
753+
ThreadsListHandle tlh;
754+
JavaThread* native_thread = get_native(tlh, thread);
753755
if (native_thread != NULL) {
754756
JfrThreadLocal::include(native_thread);
755757
} else {
@@ -759,7 +761,8 @@ void JfrJavaSupport::include(jobject thread) {
759761
}
760762

761763
bool JfrJavaSupport::is_excluded(jobject thread) {
762-
JavaThread* native_thread = get_native(thread);
764+
ThreadsListHandle tlh;
765+
JavaThread* native_thread = get_native(tlh, thread);
763766
return native_thread != NULL ? native_thread->jfr_thread_local()->is_excluded() : is_thread_excluded(thread);
764767
}
765768

0 commit comments

Comments
 (0)