Handle Thread#kill during scheduler shutdown - #476
Merged
Conversation
Assisted-By: devx/577dd101-056f-4573-9c18-d205cfd057f4
ioquatix
approved these changes
Sep 14, 2026
Assisted-By: devx/577dd101-056f-4573-9c18-d205cfd057f4
Assisted-By: devx/577dd101-056f-4573-9c18-d205cfd057f4
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.
Description
On affected CRuby versions,
Thread#killexposes the internalTAG_FATALvalue (8) through$!while the fiber scheduler is closing. Async shutdown eventually passes that value toTask#cancel, where it is rejected as an exception cause and turns graceful thread termination into aTypeError.Normalize non-exception cancellation causes at the
Task#cancelboundary so Async falls back to its regularAsync::Cancel::Cause. Add a regression test which kills a thread while its reactor owns a nested sleeping task and verifies that joining the thread does not raise.Fixes #475.
The corresponding CRuby fixes are ruby/ruby#18808 and ruby/ruby#18809.
Testing
bundle exec bake test(543 tests, 1,196 assertions)bundle exec rubocop lib/async/task.rb test/async/scheduler.rb