async: macOS: `Errno::EINVAL: Invalid argument - IO_Event_Selector_KQueue_io_wait:IO_Event_Selector_KQueue_Waiting_register`
Sometimes during the final Kernel#puts calls in an Async::Task, I get this exception:
main: sorting and printing ...
0.0s warn: Async::Task: reduce [oid=0x7e4] [ec=0x690] [pid=78132] [2024-01-16 12:01:01 +0100]
| Task may have ended with unhandled exception.
| Errno::EINVAL: Invalid argument - IO_Event_Selector_KQueue_io_wait:IO_Event_Selector_KQueue_Waiting_register
| → /usr/local/lib/ruby/gems/3.3.0/gems/async-2.8.0/lib/async/scheduler.rb:195 in `io_wait'
| /usr/local/lib/ruby/gems/3.3.0/gems/async-2.8.0/lib/async/scheduler.rb:195 in `io_wait'
| calculate_average_zmq.rb:129 in `write'
| calculate_average_zmq.rb:129 in `puts'
| calculate_average_zmq.rb:129 in `puts'
| calculate_average_zmq.rb:129 in `block (3 levels) in <top (required)>'
| calculate_average_zmq.rb:128 in `each'
| calculate_average_zmq.rb:128 in `block (2 levels) in <top (required)>'
| /usr/local/lib/ruby/gems/3.3.0/gems/async-2.8.0/lib/async/task.rb:161 in `block in run'
| /usr/local/lib/ruby/gems/3.3.0/gems/async-2.8.0/lib/async/task.rb:331 in `block in schedule'
Relevant lines in the script:
Async do |task|
task.async annotation: 'reduce' do
results = ...
warn "main: sorting and printing ..."
results.sort_by(&:first).each do |name, city|
puts format("%s=%.1f/%.1f/%.1f", name, city.min, city.tot / city.n, city.max)
end
end
end
(Yeah, this relates to the 1BRC.)
Ruby 3.3.0 Async 2.8.0 macOS 13.6.3 (Darwin 22.6.0)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (18 by maintainers)
Thanks a lot for the effort. Must have been tricky to find.
The issue is mitigated in v2.8.1 and should be properly fixed in Ruby v3.3.1 assuming the backport is done.
Okay, I isolated the problem.
https://bugs.ruby-lang.org/issues/20231
We will need to backport the PR: https://github.com/ruby/ruby/pull/9792
For now, I’ll patch
asyncto avoidio_writeuntil 3.3.1 is released.Sorry I have not had time to investigate the root cause. I’ll check it this week/end.