Wrap rb_objspace_reachable_objects_from_root with RB_VM_LOCK

rb_objspace_reachable_objects_from has it too, so I figure it's most
likely required for _from_root as well.
This commit is contained in:
KJ Tsanaktsidis 2023-11-07 22:06:33 +11:00 committed by Jean Boussier
parent 60e19a0b5f
commit 76dc327eef

28
gc.c
View File

@ -11987,19 +11987,23 @@ objspace_reachable_objects_from_root(rb_objspace_t *objspace, void (func)(const
{ {
if (during_gc) rb_bug("objspace_reachable_objects_from_root() is not supported while during_gc == true"); if (during_gc) rb_bug("objspace_reachable_objects_from_root() is not supported while during_gc == true");
rb_ractor_t *cr = GET_RACTOR(); RB_VM_LOCK_ENTER();
struct root_objects_data data = { {
.func = func, rb_ractor_t *cr = GET_RACTOR();
.data = passing_data, struct root_objects_data data = {
}; .func = func,
struct gc_mark_func_data_struct mfd = { .data = passing_data,
.mark_func = root_objects_from, };
.data = &data, struct gc_mark_func_data_struct mfd = {
}, *prev_mfd = cr->mfd; .mark_func = root_objects_from,
.data = &data,
}, *prev_mfd = cr->mfd;
cr->mfd = &mfd; cr->mfd = &mfd;
gc_mark_roots(objspace, &data.category); gc_mark_roots(objspace, &data.category);
cr->mfd = prev_mfd; cr->mfd = prev_mfd;
}
RB_VM_LOCK_LEAVE();
} }
/* /*