Skip to content

Commit 47a0439

Browse files
TEST: insert rb_gc_start() after rb_funcall to force deterministic crash
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c3e2205 commit 47a0439

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

scheduler.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,10 +1109,11 @@ VALUE rb_fiber_scheduler_blocking_operation_wait(VALUE scheduler, void* (*functi
11091109
// after all uses of `operation` (the raw pointer derived from blocking_operation)
11101110
// so the object cannot be moved while the raw pointer is live.
11111111
VALUE blocking_operation = rb_fiber_scheduler_blocking_operation_new(function, data, unblock_function, data2, flags, state);
1112-
rb_gc_register_address(&blocking_operation);
11131112

11141113
VALUE result = rb_funcall(scheduler, id_blocking_operation_wait, 1, blocking_operation);
11151114

1115+
rb_gc_start();
1116+
11161117
// Get the operation data to check if it was executed
11171118
rb_fiber_scheduler_blocking_operation_t *operation = get_blocking_operation(blocking_operation);
11181119
rb_atomic_t current_status = RUBY_ATOMIC_LOAD(operation->status);
@@ -1124,10 +1125,6 @@ VALUE rb_fiber_scheduler_blocking_operation_wait(VALUE scheduler, void* (*functi
11241125
operation->data2 = NULL;
11251126
operation->unblock_function = NULL;
11261127

1127-
// All uses of blocking_operation (directly and via the `operation` pointer)
1128-
// are complete — safe to remove from the GC root list.
1129-
rb_gc_unregister_address(&blocking_operation);
1130-
11311128
// If the blocking operation was never executed, return Qundef to signal the caller to use rb_nogvl instead
11321129
if (current_status == RB_FIBER_SCHEDULER_BLOCKING_OPERATION_STATUS_QUEUED) {
11331130
return Qundef;

0 commit comments

Comments
 (0)