Commit 79d3357
Fix GC safety of blocking_operation in rb_fiber_scheduler_blocking_operation_wait
rb_funcall(scheduler, :blocking_operation_wait, 1, blocking_operation) can
cause a fiber switch if the scheduler calls rb_fiber_scheduler_block. When
the fiber is suspended, blocking_operation may not be reachable via the
conservative GC scan of the suspended fiber's C stack.
rb_gc_register_address pins blocking_operation in the global GC root list,
which is always walked regardless of fiber state. The address is kept
registered through the last implicit use of the VALUE — including all accesses
via the raw C pointer derived from it — so that a compacting GC
cannot move the object and leave dangling.
Confirmed by reproducing the crash in io-event CI:
./configure --enable-shared --disable-install-doc --enable-yjit
See: socketry/io-event#171
ruby#16908
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 56cd26f commit 79d3357
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1111 | 1111 | | |
1112 | 1112 | | |
1113 | 1113 | | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
1114 | 1121 | | |
1115 | 1122 | | |
1116 | 1123 | | |
| |||
0 commit comments