Commit febd60f
committed
Fix forking in multi-ractor scenario
When there are multiple Ractors, there is a chance that one Ractor
triggers GC when another Ractor has just stopped all MMTk GC work
threads in order to fork. If this happens, the forking thread will be
blocking waiting for the Ractor sched barrier, and the Ractor that
triggered GC will be waiting for GC threads to finish GC, which will
never happen.
We move the invocations of `rb_gc_before_fork()` and
`rb_gc_after_fork()` inside the `RB_VM_LOCKING() { ... }` block in
`rb_fork_ruby`. By doing this, either the forking Ractor will wait for
GC to finish before stopping GC worker threads, or the Ractor that
triggers GC cannot stop other threads until the forking ractor respawned
GC worker threads.
We also hold the VM lock when running finalizers when the VM is about to
exits.1 parent b669f3e commit febd60f
2 files changed
+20
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
937 | 937 | | |
938 | 938 | | |
939 | 939 | | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | | - | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
954 | 957 | | |
| 958 | + | |
955 | 959 | | |
956 | 960 | | |
957 | 961 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1575 | 1575 | | |
1576 | 1576 | | |
1577 | 1577 | | |
1578 | | - | |
1579 | 1578 | | |
1580 | 1579 | | |
1581 | 1580 | | |
1582 | 1581 | | |
1583 | 1582 | | |
1584 | 1583 | | |
1585 | | - | |
1586 | | - | |
1587 | 1584 | | |
1588 | 1585 | | |
1589 | 1586 | | |
| |||
4138 | 4135 | | |
4139 | 4136 | | |
4140 | 4137 | | |
| 4138 | + | |
4141 | 4139 | | |
4142 | 4140 | | |
| 4141 | + | |
4143 | 4142 | | |
4144 | 4143 | | |
4145 | 4144 | | |
| |||
0 commit comments