Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GetThreadStateTest #18660

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Fix GetThreadStateTest #18660

merged 2 commits into from
Dec 20, 2023

Conversation

babsingh
Copy link
Contributor

@babsingh babsingh commented Dec 20, 2023

Acquire VThreadInspector before vmThreadListMutex to avoid deadlock

VirtualThreads.park performs operations in the below order:
Set VThreadInspector to -1 and then acquire vmThreadListMutex

JVMTI GetThreadState -> ... -> getVMThread follows the below order:
Acquire vmThreadListMutex and then spin until VThreadInspector != -1

A deadlock occurs because the order of operations is inconsistent
between VirtualThreads.park and JVMTI GetThreadState.

To resolve the deadlock, the operations in getVMThread are swapped
to match the operations in VirtualThreads.park:
Acquire VThreadInspector and then acquire vmThreadListMutex

VirtualThread State: *PINNED is identical to *PARKED

RI and JTReg tests expect the same JVMTI thread state for

  • PARKED and PINNED
  • TIMED_PARKED and TIMED_PINNED

Related: #18642

Signed-off-by: Babneet Singh [email protected]

@babsingh
Copy link
Contributor Author

jenkins test sanity.functional,sanity.openjdk,extended.openjdk alinux,aix jdk21

@babsingh
Copy link
Contributor Author

@babsingh babsingh requested review from tajila and pshipton December 20, 2023 05:18
VirtualThreads.park performs operations in the below order:
Set VThreadInspector to -1 and then acquire vmThreadListMutex

JVMTI GetThreadState -> ... -> getVMThread follows the below order:
Acquire vmThreadListMutex and then spin until VThreadInspector != -1

A deadlock occurs because the order of operations is inconsistent
between VirtualThreads.park and JVMTI GetThreadState.

To resolve the deadlock, the operations in getVMThread are swapped
to match the operations in VirtualThreads.park:
Acquire VThreadInspector and then acquire vmThreadListMutex

Related: eclipse-openj9#18642

Signed-off-by: Babneet Singh <[email protected]>
RI and JTReg tests expect the same JVMTI thread state for
- PARKED and PINNED
- TIMED_PARKED and TIMED_PINNED

Related: eclipse-openj9#18642

Signed-off-by: Babneet Singh <[email protected]>
@babsingh
Copy link
Contributor Author

jenkins test sanity.functional,sanity.openjdk,extended.openjdk alinux,aix 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.

3 participants