Use a real Ruby mutex in rb_io_close_wait_list #7884
Merged
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.
Because a thread calling IO#close now blocks in a native condvar wait, it's possible for there to be no threads left to actually handle incoming signals/ubf calls/etc.
This manifested as failing tests on Solaris 10 (SPARC), because:
This results in a deadlock.
The fix is to use a real Ruby mutex for the close lock; that way, the closing thread goes into sigwait-sleep and can keep trying to interrupt the select(2) thread.
See the discussion in: #7865
In that linked PR above, I also said "nogvl_wait_for should wait not only on the actual FD that was requested, but also on the sigwait FD (if it's available).". I think I want to do that as well. But this patch seems sufficient to solve the deadlock I introduced, and the tests pass on the Solaris VM i'm using.
CC @mame and @ioquatix