Skip to content

(0.51) JEP491: Never Deflate Monitors and Synchronize virtualThreadWaitCount #21392

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

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

babsingh
Copy link
Contributor

Currently, there are timing holes between
JVM_TakeVirtualThreadListToUnblock and monitor deflation. A monitor can
be deflated while it is being accessed in
JVM_TakeVirtualThreadListToUnblock. This leads to a NULL dereference
causing a segfault. Adding more synchronization will cause a
significant overhead in the object monitor exit path. Until an
efficient solution is developed, the policy to never deflate will be
employed in order to support JEP491. Since the current JEP491
implementation always inflates monitors before usage, deflating will be
counter-productive.

Also, added a null check for syncObjectMonitor in
JVM_TakeVirtualThreadListToUnblock to ensure that the monitor is
inflated before operations are performed on it.

Operations on J9ObjectMonitor's virtualThreadWaitCount field may
happen out of sequence. To ensure correct ordering and consistency,
atomics have been employed to modify this field.

Related: #20705

Backport of #21384

Currently, there are timing holes between
JVM_TakeVirtualThreadListToUnblock and monitor deflation. A monitor can
be deflated while it is being accessed in
JVM_TakeVirtualThreadListToUnblock. This leads to a NULL dereference
causing a segfault. Adding more synchronization will cause a
significant overhead in the object monitor exit path. Until an
efficient solution is developed, the policy to never deflate will be
employed in order to support JEP491. Since the current JEP491
implementation always inflates monitors before usage, deflating will be
counter-productive.

Also, added a null check for syncObjectMonitor in
JVM_TakeVirtualThreadListToUnblock to ensure that the monitor is
inflated before operations are performed on it.

Operations on J9ObjectMonitor's virtualThreadWaitCount field may
happen out of sequence. To ensure correct ordering and consistency,
atomics have been employed to modify this field.

Related: eclipse-openj9#20705

Signed-off-by: Babneet Singh <[email protected]>
@babsingh babsingh requested a review from tajila March 18, 2025 20:32
@tajila tajila merged commit 3db5491 into eclipse-openj9:v0.51.0-release Mar 19, 2025
2 checks passed
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