Skip to content

Commit 84bc1f0

Browse files
committed
Box: Mark boxes when a class/module is originally defined in it.
When a class/module defined by extension libraries in a box, checking types of instances of the class needs to access its data type (rb_data_type_t). So if a class still exists (not GCed), the box must exist too (to be marked).
1 parent 75f8a11 commit 84bc1f0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

gc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3154,12 +3154,18 @@ rb_gc_mark_children(void *objspace, VALUE obj)
31543154
foreach_args.objspace = objspace;
31553155
foreach_args.obj = obj;
31563156
rb_class_classext_foreach(obj, gc_mark_classext_module, (void *)&foreach_args);
3157+
if (BOX_USER_P(RCLASS_PRIME_BOX(obj))) {
3158+
gc_mark_internal(RCLASS_PRIME_BOX(obj)->box_object);
3159+
}
31573160
break;
31583161

31593162
case T_ICLASS:
31603163
foreach_args.objspace = objspace;
31613164
foreach_args.obj = obj;
31623165
rb_class_classext_foreach(obj, gc_mark_classext_iclass, (void *)&foreach_args);
3166+
if (BOX_USER_P(RCLASS_PRIME_BOX(obj))) {
3167+
gc_mark_internal(RCLASS_PRIME_BOX(obj)->box_object);
3168+
}
31633169
break;
31643170

31653171
case T_ARRAY:

0 commit comments

Comments
 (0)