Skip to content

Commit 06356a3

Browse files
Remove timer-based runtime advance from interrupt handler
The approach of setting ec->runtime = ec->quantum inside rb_threadptr_execute_interrupts caused a SystemStackError on Windows when a timer interrupt fired during @main.transfer inside the base Scheduler: preemption called scheduler.yield -> kernel_sleep(0) -> block -> @main.transfer -> recursion. Remove the timer-based advance entirely. Under YARV the back-edge counter in rb_vm_check_ints provides preemption without this. Under YJIT the timing-based preemption tests are already guarded with omit/skip so they don't run. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent dcc2eaf commit 06356a3

1 file changed

Lines changed: 0 additions & 9 deletions

File tree

thread.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,15 +2719,6 @@ rb_threadptr_execute_interrupts(rb_thread_t *th, int blocking_timing)
27192719
0, 0, 0, Qundef);
27202720

27212721
rb_thread_schedule_limits(limits_us);
2722-
2723-
// Advance the fiber's scheduling runtime to the quantum so that
2724-
// the next rb_vm_check_ints call (the next safe point) triggers
2725-
// rb_fiber_scheduler_maybe_preempt. This provides timer-based
2726-
// fiber preemption for JIT-compiled code that bypasses the
2727-
// back-edge counter without executing Ruby code in interrupt context.
2728-
if (th->ec->thread_ptr->blocking == 0 && !th->ec->preempted) {
2729-
th->ec->runtime = th->ec->quantum;
2730-
}
27312722
}
27322723
}
27332724
return ret;

0 commit comments

Comments
 (0)