Project

General

Profile

Actions

Bug #17415

closed

IO read gets blocked with Fiber Scheduler on Windows

Added by dsh0416 (Delton Ding) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.0dev (2020-12-19 master 4735a5b9d2) [x64-mingw32]
[ruby-core:101582]

Description

Here is the given example code for reproduction the bug:

rd, wr = IO.pipe
scheduler = Evt::Scheduler.new # Any scheduler including the test scheduler in the ruby repo could reproduce the same problem.

message = nil
Fiber.set_scheduler scheduler

Fiber.schedule do
  wr.write(MESSAGE)
  wr.close
end
  
Fiber.schedule do
  message = rd.read(20)
  rd.close
end

scheduler.run

assert_equal MESSAGE, message
assert rd.closed?
assert wr.closed?

When running under Linux, FreeBSD or macOS, the code works fine. But when running under Windows:

#...

Fiber.schedule do
  message = rd.read(20) # !!! -> Got blocked here
  rd.close
end

#...

Since some of the files don't support non-blocking on Windows, I double checked with the following code:

a, b = IO.pipe
b.write_nonblock("Test")
a.read_nonblock(4) # => "Test"

which works totally fine on Windows. I suppose some kind of IO non-blocking setup is not working properly under Windows.

Still investigating the details for patching...

Actions

Also available in: Atom PDF