Free all remaining objects in rb_objspace_free_objects

rb_objspace_call_finalizer didn't free fibers and neither did
rb_objspace_free_objects, which caused fibers to be reported as leaked
when using RUBY_FREE_AT_EXIT. This commit changes rb_objspace_free_objects
to free all remaining Ruby objects.
This commit is contained in:
Peter Zhu 2024-02-05 14:41:29 -05:00
parent 1c120023f1
commit a50e35888b

14
gc.c
View File

@ -3810,7 +3810,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
RB_DEBUG_COUNTER_INC(obj_imemo_constcache); RB_DEBUG_COUNTER_INC(obj_imemo_constcache);
break; break;
} }
return TRUE; break;
default: default:
rb_bug("gc_sweep(): unknown data type 0x%x(%p) 0x%"PRIxVALUE, rb_bug("gc_sweep(): unknown data type 0x%x(%p) 0x%"PRIxVALUE,
@ -3822,6 +3822,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
return FALSE; return FALSE;
} }
else { else {
RBASIC(obj)->flags = 0;
return TRUE; return TRUE;
} }
} }
@ -4616,16 +4617,11 @@ rb_objspace_free_objects(rb_objspace_t *objspace)
for (; p < pend; p += stride) { for (; p < pend; p += stride) {
VALUE vp = (VALUE)p; VALUE vp = (VALUE)p;
switch (BUILTIN_TYPE(vp)) { switch (BUILTIN_TYPE(vp)) {
case T_DATA: { case T_NONE:
if (rb_obj_is_mutex(vp) || rb_obj_is_thread(vp) || rb_obj_is_main_ractor(vp)) { case T_SYMBOL:
obj_free(objspace, vp);
}
break;
}
case T_ARRAY:
obj_free(objspace, vp);
break; break;
default: default:
obj_free(objspace, vp);
break; break;
} }
} }