Commit 2e301ec
Fix GC safety and write barriers in worker_pool.c
1. RB_GC_GUARD(_blocking_operation) in worker_pool_call
The _blocking_operation VALUE argument is on the calling fiber's C stack.
The GC finds it via conservative scan, marks the underlying TypedData
object, and prevents collection — keeping the raw C pointer extracted
before the fiber switch valid throughout the worker's execution.
RB_GC_GUARD ensures the compiler doesn't treat the VALUE as dead before
the end of the function.
2. RUBY_TYPED_WB_PROTECTED + compact function
Without WB_PROTECTED, RB_OBJ_WRITE (used at worker creation) installed
no write barrier. A new compact function updates worker->thread via
rb_gc_location for proper compacting GC support.
3. rb_gc_mark_movable for thread objects
Changed from rb_gc_mark (which pins) to rb_gc_mark_movable so threads
can be relocated by the compacting GC.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 218d53a commit 2e301ec
1 file changed
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | 94 | | |
96 | 95 | | |
97 | | - | |
98 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
99 | 108 | | |
100 | 109 | | |
101 | 110 | | |
| |||
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
110 | | - | |
111 | | - | |
| 119 | + | |
| 120 | + | |
112 | 121 | | |
113 | 122 | | |
114 | 123 | | |
| |||
375 | 384 | | |
376 | 385 | | |
377 | 386 | | |
| 387 | + | |
| 388 | + | |
378 | 389 | | |
379 | 390 | | |
380 | 391 | | |
| |||
0 commit comments