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

(0.43) Fix GetThreadStateTest #18661

Merged
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

Port of #18660 for 0.43

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

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]>
@pshipton pshipton merged commit a61fe6f into eclipse-openj9:v0.43.0-release Dec 20, 2023
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