Skip to content

[JDK21] Fix jvmtiSuspendThread and jvmtiGetCarrierThread - #17999

Merged
gacholio merged 2 commits into
eclipse-openj9:masterfrom
babsingh:jvmti_fixes
Aug 23, 2023
Merged

[JDK21] Fix jvmtiSuspendThread and jvmtiGetCarrierThread #17999
gacholio merged 2 commits into
eclipse-openj9:masterfrom
babsingh:jvmti_fixes

Conversation

@babsingh

@babsingh babsingh commented Aug 22, 2023

Copy link
Copy Markdown
Contributor

Commit 1: Fix deadlock that occurs while suspending threads through JVMTI

getVMThread can cause a deadlock for a virutal thread if the thread is
already suspended. The suspended virtual thread halts during the mount
or unmount phase while the virtualThreadInspectorCount is set to -1.
Meanwhile, acquireVThreadInspector waits indefinitely for the
virtualThreadInspectorCount to be set to 0 in the mount or unmount
phase. To prevent the deadlock, jvmtiSuspendThread should return an
error for already suspended threads without invoking
getVMThread -> acquireVThreadInspector. This approach an be taken for
both platform and virtual threads.

Commit 2: Fix jvmtiGetCarrierThread

An unmounted virtual thread has no carrier thread.

targetThread is NULL for an unmounted virtual thread.

A NULL check has been added for the targetThread to prevent a segfault.

Related: #17933

Signed-off-by: Babneet Singh sbabneet@ca.ibm.com

An unmounted virtual thread has no carrier thread.

targetThread is NULL for an unmounted virtual thread.

A NULL check has been added for the targetThread to prevent a segfault.

Related: eclipse-openj9#17933

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
@babsingh
babsingh marked this pull request as ready for review August 22, 2023 20:54
@babsingh
babsingh requested a review from gacholio August 22, 2023 20:55
@babsingh

Copy link
Copy Markdown
Contributor Author

@gacholio Requesting your review.

Comment thread runtime/jvmti/suspendhelper.cpp Outdated
getVMThread can cause a deadlock for a virutal thread if the thread is
already suspended. The suspended virtual thread halts during the mount
or unmount phase while the virtualThreadInspectorCount is set to -1.
Meanwhile, acquireVThreadInspector waits indefinitely for the
virtualThreadInspectorCount to be set to 0 in the mount or unmount
phase. To prevent the deadlock, jvmtiSuspendThread should return an
error for already suspended threads without invoking
getVMThread -> acquireVThreadInspector. This approach an be taken for
both platform and virtual threads.

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
@gacholio

Copy link
Copy Markdown
Contributor

jenkins compile win jdk8

@gacholio

Copy link
Copy Markdown
Contributor

jenkins test sanity zlinux jdk21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants