Skip to content

Commit

Permalink
8307156: native_thread not protected by TLH
Browse files Browse the repository at this point in the history
Reviewed-by: phh, mgronlun
Backport-of: 0c6529d2d38a668f74936cca7803ca9de1a05d49
  • Loading branch information
shipilev committed Jun 29, 2023
1 parent 295cf44 commit 4dd316b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/hotspot/share/jfr/jni/jfrJavaSupport.cpp
Expand Up @@ -726,20 +726,21 @@ static bool check_exclusion_state_on_thread_start(JavaThread* jt) {
return true;
}

static JavaThread* get_native(jobject thread) {
ThreadsListHandle tlh;
static JavaThread* get_native(ThreadsListHandle& tlh, jobject thread) {
JavaThread* native_thread = NULL;
(void)tlh.cv_internal_thread_to_JavaThread(thread, &native_thread, NULL);
return native_thread;
}

jlong JfrJavaSupport::jfr_thread_id(jobject thread) {
JavaThread* native_thread = get_native(thread);
ThreadsListHandle tlh;
JavaThread* native_thread = get_native(tlh, thread);
return native_thread != NULL ? JFR_THREAD_ID(native_thread) : 0;
}

void JfrJavaSupport::exclude(jobject thread) {
JavaThread* native_thread = get_native(thread);
ThreadsListHandle tlh;
JavaThread* native_thread = get_native(tlh, thread);
if (native_thread != NULL) {
JfrThreadLocal::exclude(native_thread);
} else {
Expand All @@ -749,7 +750,8 @@ void JfrJavaSupport::exclude(jobject thread) {
}

void JfrJavaSupport::include(jobject thread) {
JavaThread* native_thread = get_native(thread);
ThreadsListHandle tlh;
JavaThread* native_thread = get_native(tlh, thread);
if (native_thread != NULL) {
JfrThreadLocal::include(native_thread);
} else {
Expand All @@ -759,7 +761,8 @@ void JfrJavaSupport::include(jobject thread) {
}

bool JfrJavaSupport::is_excluded(jobject thread) {
JavaThread* native_thread = get_native(thread);
ThreadsListHandle tlh;
JavaThread* native_thread = get_native(tlh, thread);
return native_thread != NULL ? native_thread->jfr_thread_local()->is_excluded() : is_thread_excluded(thread);
}

Expand Down

1 comment on commit 4dd316b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.