Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression when IO.wait_* or rb_io_wait is interrupted by Thread#kill #3504

Closed
larskanis opened this issue Mar 22, 2024 · 1 comment
Closed
Assignees
Labels

Comments

@larskanis
Copy link
Contributor

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:

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
@andrykonchin andrykonchin self-assigned this Mar 26, 2024
@andrykonchin
Copy link
Member

Thank you for the report, we'll look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants