Commit 7978b22
committed
Fix GCC optimization bug eliminating rb_gc_before_fork()
Previously (with -O3), `rb_gc_before_fork` did nothing (it just
returned). Now, it executes an atomic instruction to force memory
consistency before the operating system forks the process. This prevents
stale heap objects from persisting across fork, which can lead to double
frees in the child process.
Old Version:
```
0000000000071410 <rb_gc_before_fork>:
71410: c3 ret <-- Return immediately
...
```
New Version:
```
0000000000071490 <rb_gc_before_fork>:
71490: f0 48 83 0c 24 00 lock orq $0x0,(%rsp)
71496: c3 ret
...
```1 parent 130c37d commit 7978b22
1 file changed
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5618 | 5618 | | |
5619 | 5619 | | |
5620 | 5620 | | |
| 5621 | + | |
5621 | 5622 | | |
5622 | 5623 | | |
5623 | 5624 | | |
| |||
0 commit comments