Commit 6ae5083
committed
gc: prevent LTO from eliminating rb_gc_before_fork
GCC LTO with -flto=auto creates a constprop clone of rb_fork_ruby where
rb_multi_ractor_p() is constant false. In that clone, rb_gc_vm_barrier()
and RB_GC_VM_LOCK() are both no-ops, so rb_gc_impl_before_fork reduces
to a trivial store and GCC eliminates the entire call chain. This leaves
no GC barrier before fork(2).
RBIMPL_ATTR_NOINLINE() on rb_gc_before_fork prevents GCC from inlining
it into the constprop clone, forcing it to treat the call as having
unknown side effects.
Additionally, call gc_rest() at the top of rb_gc_impl_before_fork to
complete any in-progress incremental GC cycle before forking. This
ensures the child does not inherit a mid-cycle heap.1 parent 8913322 commit 6ae5083
2 files changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5435 | 5435 | | |
5436 | 5436 | | |
5437 | 5437 | | |
| 5438 | + | |
5438 | 5439 | | |
5439 | 5440 | | |
5440 | 5441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9407 | 9407 | | |
9408 | 9408 | | |
9409 | 9409 | | |
| 9410 | + | |
| 9411 | + | |
9410 | 9412 | | |
9411 | 9413 | | |
9412 | 9414 | | |
| |||
0 commit comments