[Bug #21099] Fix GC when Ractor list not initialized
When the Ractor list is not initialized and a GC is ran at boot, then it would crash because the newobj_cache of the main Ractor is not cleared. This commit changes it to use ruby_single_main_ractor when it's available and iterate over the Ractor list when we have multiple Ractors.
This commit is contained in:
parent
4cfc904d97
commit
a084fef9af
Notes:
git
2025-01-30 15:11:06 +00:00
15
gc.c
15
gc.c
@ -250,8 +250,19 @@ void
|
||||
rb_gc_ractor_newobj_cache_foreach(void (*func)(void *cache, void *data), void *data)
|
||||
{
|
||||
rb_ractor_t *r = NULL;
|
||||
ccan_list_for_each(&GET_VM()->ractor.set, r, vmlr_node) {
|
||||
func(r->newobj_cache, data);
|
||||
if (RB_LIKELY(ruby_single_main_ractor)) {
|
||||
GC_ASSERT(
|
||||
ccan_list_empty(&GET_VM()->ractor.set) ||
|
||||
(ccan_list_top(&GET_VM()->ractor.set, rb_ractor_t, vmlr_node) == ruby_single_main_ractor &&
|
||||
ccan_list_tail(&GET_VM()->ractor.set, rb_ractor_t, vmlr_node) == ruby_single_main_ractor)
|
||||
);
|
||||
|
||||
func(ruby_single_main_ractor->newobj_cache, data);
|
||||
}
|
||||
else {
|
||||
ccan_list_for_each(&GET_VM()->ractor.set, r, vmlr_node) {
|
||||
func(r->newobj_cache, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user