call Thread.pass just after Thread.stop#1148
Merged
Merged
Conversation
The following `test_irb_fg_jobs_and_kill_commands` expects that after `fg 0`
Thread#1 should be `sleep_forever`.
```ruby
def test_irb_fg_jobs_and_kill_commands
out = run_ruby_file do
type "irb"
type "fg 0"
type "jobs"
type "kill 1"
type "exit"
end
assert_match(/#0->irb on main \(#<Thread:0x.+ run>: running\)/, out)
assert_match(/ruby#1->irb#1 on main \(#<Thread:0x.+ sleep_forever>: stop\)/, out)
end
end
```
However, the following switching method expects that
```
def switch(key)
th, irb = search(key)
...
th.run
Thread.stop
```
(1) resume target thread
(2) Suspend current thread (-> sleep_forever)
`th.run` calls `Thread.pass` internally and maybe the context swtich to
resumed thread (#0 in this case).
Thread #0 should switch to ruby#1 before `jobs` command.
Until Ruby 3.4, I/O operation makes context switching to another ready thread,
so that several I/O output can resume `ruby#1`.
However, our planning new thread scheduler delays context switching on I/O
operations, so the thread ruby#1 still running (because `Thread.stop` is not called yet).
This patch add `Thraed.pass` to make workaround for this test.
ko1
added a commit
to ko1/ruby
that referenced
this pull request
Dec 12, 2025
tompng
approved these changes
Dec 12, 2025
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.
The following
test_irb_fg_jobs_and_kill_commandsexpects that afterfg 0Thread#1 should besleep_forever.However, the following switching method expects that
(1) resume target thread
(2) Suspend current thread (-> sleep_forever)
th.runcallsThread.passinternally and maybe the context swtich to resumed thread (#0 in this case).Thread #0 should switch to #1 before
jobscommand. Until Ruby 3.4, I/O operation makes context switching to another ready thread, so that several I/O output can resume#1.However, our planning new thread scheduler delays context switching on I/O operations, so the thread #1 still running (because
Thread.stopis not called yet).This patch add
Thraed.passto make workaround for this test.