Skip to content

Commit 10807b5

Browse files
Add io_close to TestScheduler.
In Ruby 4.1, IO#close without a scheduler io_close hook falls through to maygvl_close with RB_NOGVL_OFFLOAD_SAFE, which calls rb_fiber_scheduler_blocking_operation_wait. With a worker-pool scheduler this causes a fiber switch, and GC compaction can then move the blocking_operation VALUE — crashing in get_blocking_operation. Fix: add io_close to TestScheduler delegating to @selector.io_close so Ruby marks done=1 and skips maygvl_close entirely. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 218d53a commit 10807b5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

fixtures/io/event/test_scheduler.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ def fiber_interrupt(fiber, exception)
114114
unblock(nil, FiberInterrupt.new(fiber, exception))
115115
end
116116

117+
def io_close(io)
118+
@selector.io_close(io) if @selector.respond_to?(:io_close)
119+
end
120+
117121
def io_wait(io, events, timeout = nil)
118122
fiber = Fiber.current
119123

0 commit comments

Comments
 (0)