Commit 7d8480f
committed
Use EC saved in GC for root marking
Since EC is thread-local, we previously used rb_gc_worker_thread_set_vm_context
in MMTk worker threads to temporarily set the EC. However, this was inelegant
and also occasionally caused crashes when marking threads/fibers for the
current EC since it will mark the current machine stack twice (once during
root marking and once for the fiber). However, since the machine
stack is actively being used, the contents may be different when marking
the fiber. Since all objects on the machine stack are pinned, this may
cause an unpinned object to be pinned, which is not allowed in Immix.
The following crash can be observed:
Object 0x200fffbc7d8 is trying to pin 0x200ffc80188
0: mmtk_ruby::handle_gc_thread_panic
1: mmtk_ruby::set_panic_hook::{{closure}}
2: <alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::Fn<(&'a std::panic::PanicHookInfo<'b>,), Output = ()> + core::marker::Sync + core::marker::Send> as core::ops::function::Fn<(&std::panic::PanicHookInfo,)>>::call
at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/alloc/src/boxed.rs:2254:9
3: std::panicking::panic_with_hook
at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/std/src/panicking.rs:833:13
4: std::panicking::panic_handler::{closure#0}
at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/std/src/panicking.rs:698:13
5: std::sys::backtrace::__rust_end_short_backtrace::<std::panicking::panic_handler::{closure#0}, !>
at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/std/src/sys/backtrace.rs:182:18
6: __rustc::rust_begin_unwind
at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/std/src/panicking.rs:689:5
7: core::panicking::panic_fmt
at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/core/src/panicking.rs:80:14
8: <mmtk_ruby::scanning::VMScanning as mmtk::vm::scanning::Scanning<mmtk_ruby::Ruby>>::scan_object_and_trace_edges::{{closure}}
9: mmtk_ruby::abi::ObjectClosure::c_function_registered
10: rb_mmtk_call_object_closure
at gc/mmtk/mmtk.c:976:19
11: rb_gc_impl_mark_and_pin
at gc/mmtk/mmtk.c:1008:5
12: rb_gc_impl_mark_and_pin
at gc/mmtk/mmtk.c:1004:1
13: gc_mark_maybe_internal
at gc.c:2908:5
14: gc_mark_maybe_internal
at gc.c:2906:1
15: gc_mark_maybe_each_location
at gc.c:2939:5
16: gc_mark_maybe_each_location
at gc.c:2937:1
17: each_location
at gc.c:2924:9
18: each_location_ptr
at gc.c:2933:5
19: each_location_ptr
at gc.c:2930:1
20: rb_gc_mark_machine_context
at gc.c:3200:5
21: rb_execution_context_mark
at vm.c:3768:9
22: cont_mark
at cont.c:1155:5
23: fiber_mark
at cont.c:1284:5
24: rb_mmtk_call_gc_mark_children
at gc/mmtk/mmtk.c:318:5
25: <mmtk_ruby::scanning::VMScanning as mmtk::vm::scanning::Scanning<mmtk_ruby::Ruby>>::scan_object_and_trace_edges::{{closure}}1 parent 1c39cc8 commit 7d8480f
7 files changed
Lines changed: 42 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
195 | 194 | | |
196 | 195 | | |
197 | 196 | | |
198 | 197 | | |
199 | 198 | | |
200 | 199 | | |
201 | 200 | | |
| 201 | + | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| |||
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| 629 | + | |
629 | 630 | | |
630 | 631 | | |
631 | 632 | | |
| |||
804 | 805 | | |
805 | 806 | | |
806 | 807 | | |
| 808 | + | |
807 | 809 | | |
808 | 810 | | |
809 | 811 | | |
| |||
891 | 893 | | |
892 | 894 | | |
893 | 895 | | |
| 896 | + | |
894 | 897 | | |
895 | 898 | | |
896 | 899 | | |
| |||
3238 | 3241 | | |
3239 | 3242 | | |
3240 | 3243 | | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
3241 | 3257 | | |
3242 | 3258 | | |
3243 | 3259 | | |
3244 | | - | |
| 3260 | + | |
3245 | 3261 | | |
3246 | 3262 | | |
3247 | 3263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
| 686 | + | |
| 687 | + | |
686 | 688 | | |
687 | 689 | | |
688 | 690 | | |
| |||
1652 | 1654 | | |
1653 | 1655 | | |
1654 | 1656 | | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
1655 | 1665 | | |
1656 | 1666 | | |
1657 | 1667 | | |
| |||
6767 | 6777 | | |
6768 | 6778 | | |
6769 | 6779 | | |
| 6780 | + | |
| 6781 | + | |
6770 | 6782 | | |
6771 | 6783 | | |
6772 | 6784 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | | - | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | 256 | | |
260 | | - | |
261 | 257 | | |
262 | 258 | | |
263 | 259 | | |
| |||
784 | 780 | | |
785 | 781 | | |
786 | 782 | | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
787 | 791 | | |
788 | 792 | | |
789 | 793 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3764 | 3764 | | |
3765 | 3765 | | |
3766 | 3766 | | |
3767 | | - | |
3768 | | - | |
| 3767 | + | |
| 3768 | + | |
3769 | 3769 | | |
3770 | 3770 | | |
3771 | 3771 | | |
| |||
0 commit comments