Narrow deadlock check for sibling fibers locking mutex#9226
Merged
headius merged 2 commits intojruby:masterfrom Feb 10, 2026
Merged
Narrow deadlock check for sibling fibers locking mutex#9226headius merged 2 commits intojruby:masterfrom
headius merged 2 commits intojruby:masterfrom
Conversation
* Only raise deadlock error when two different fibers from the same thread attempt to lock (jruby#9218). * Store the real parent thread as the locking thread for deadlock checks (fixes second case added in spec). Fixes jruby#9218
headius
added a commit
to headius/jruby
that referenced
this pull request
Feb 24, 2026
In jruby#9226 a user discovered that thread interrupt during an attempt to lock a mutex may render that mutex unusable from any other fiber, even if it did not successfully lock. This spec tries to trigger that state by having one thread loop while triggering a raise interrupt on another thread that repeatedly locks a mutex from within fibers. This may not always fail when it is broken due to the timing issues involved in triggering the interrupt after the lock was acquired but before interrupts have been handled by the fiber, but 10x seems sufficient to trigger the bug on JRuby.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix and specs for when multiple sibling fibers from the same thread attempt to lock the same mutex.
Additional fix to cover the unreported case of two separate fibers both locking (original case from #9218 was parent thread locks and then a fiber locks). This is the second case added in the specs.