require "io/wait"
describe "wait_readable" do
it "should stop waiting on Thread#kill" do
rd, _wr = IO.pipe
start = Time.now
t = Thread.new do
rd.wait_readable(1)
end
sleep 0.1
t.kill
sleep 0.1
puts t.backtrace
t.join
expect( Time.now - start ).to be < 0.9
end
end
In Truffleruby-23.x and MRI this looks like so:
rspec test-wait_io.rb
.
Finished in 0.20932 seconds (files took 0.1265 seconds to load)
1 example, 0 failures
But in Truffleruby-24.0.0 this fails, because the poll is not interrupted:
rspec test-wait_io.rb
<internal:core> core/truffle/polyglot.rb:334:in `execute'
<internal:core> core/truffle/polyglot.rb:334:in `call'
<internal:core> core/posix.rb:142:in `truffleposix_poll_single_fd'
<internal:core> core/posix.rb:95:in `truffleposix_poll_single_fd'
<internal:core> core/truffle/io_operations.rb:262:in `poll'
/home/lars/.rvm/rubies/truffleruby-24.0.0/lib/truffle/io/wait.rb:25:in `wait_readable'
/home/lars/comcard/ruby-pg/test-wait_io.rb:8:in `block (3 levels) in <top (required)>'
F
Failures:
1) wait_readable should stop waiting on Thread#kill
Failure/Error: expect( Time.now - start ).to be < 0.9
expected: < 0.9
got: 1.017792
# ./test-wait_io.rb:17:in `block (2 levels) in <top (required)>'
Finished in 1.1 seconds (files took 0.42542 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./test-wait_io.rb:4 # wait_readable should stop waiting on Thread#kill
Since Truffleruby-24.0.0 there is a regression regarding interruptions while waiting for IO.
This rose up in ruby-pg here: https://github.com/ged/ruby-pg/actions/runs/8393741842/job/22989402958#step:12:1202 but it is reproducible with pure ruby code like this:
In Truffleruby-23.x and MRI this looks like so:
But in Truffleruby-24.0.0 this fails, because the
poll
is not interrupted: