Skip to content

Conversation

@headius
Copy link
Member

@headius headius commented Jan 22, 2025

CRuby semantics for an interrupt during lock appear to ensure that the lock is released before propagating any interrupt exception. This poll was added without such behavior, leading to locks being left locked even though a thread interrupt happened. This in turn breaks some semantics of Mutex#synchronize, since the lock call does not happen within the try/finally that would release it, so any exception raised will exit synchronize with the lock still locked.

The fix here wraps the additional poll with try/catch to ensure poll-triggered exceptions release the lock before propagating.

Fixes #8585

CRuby semantics for an interrupt during lock appear to ensure that
the lock is released before propagating any interrupt exception.
This poll was added without such behavior, leading to locks being
left locked even though a thread interrupt happened. This in turn
breaks some semantics of Mutex#synchronize, since the lock call
does not happen within the try/finally that would release it, so
any exception raised will exit synchronize with the lock still
locked.

The fix here wraps the additional poll with try/catch to ensure
poll-triggered exceptions release the lock before propagating.

Fixes jruby#8585
@headius headius added this to the JRuby 9.4.11.0 milestone Jan 22, 2025
@headius headius self-assigned this Jan 22, 2025
@headius headius marked this pull request as ready for review January 23, 2025 18:33
@headius headius merged commit 1c74b40 into jruby:master Jan 23, 2025
95 checks passed
@headius headius deleted the release_lock_if_interrupted branch January 23, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thread interrupt can leave Mutex locked in synchronize

1 participant