Commit 290a3ec
Reset runtime and preempted in rb_fiber_atfork, add test
The child process inherits the parent's root fiber state at fork time.
rb_fiber_atfork already reset quantum to the default but left runtime
and preempted untouched. A child forked while a fiber had accumulated
runtime or had preempted=1 would start with stale scheduling state,
potentially triggering a spurious immediate preemption on the first
back-edge check. Reset all three fields consistently, matching what
rb_threadptr_root_fiber_setup does for a freshly created root fiber.
Add test_fork_resets_fiber_scheduling_state to verify that a child
forked from a fiber with accumulated runtime starts with runtime near
zero and quantum at the default value.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent d0e2242 commit 290a3ec
2 files changed
Lines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2998 | 2998 | | |
2999 | 2999 | | |
3000 | 3000 | | |
3001 | | - | |
3002 | 3001 | | |
3003 | 3002 | | |
3004 | 3003 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
430 | 463 | | |
431 | 464 | | |
432 | 465 | | |
| |||
0 commit comments