Skip to content

Commit bbcc378

Browse files
committed
Skip updating max_iv_count when the namespace cannot be determined
1 parent c2c5b05 commit bbcc378

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

gc.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,9 +3192,14 @@ rb_gc_mark_children(void *objspace, VALUE obj)
31923192
if (fields_count) {
31933193
VALUE klass = RBASIC_CLASS(obj);
31943194

3195-
// Increment max_iv_count if applicable, used to determine size pool allocation
3196-
if (RCLASS_MAX_IV_COUNT(klass) < fields_count) {
3197-
RCLASS_WRITE_MAX_IV_COUNT(klass, fields_count);
3195+
// Skip updating max_iv_count if the prime classext is not writable
3196+
// because GC context doesn't provide information about namespaces.
3197+
if (RCLASS_PRIME_CLASSEXT_WRITABLE_P(klass)) {
3198+
VM_ASSERT(rb_shape_obj_too_complex_p(klass));
3199+
// Increment max_iv_count if applicable, used to determine size pool allocation
3200+
if (RCLASS_MAX_IV_COUNT(klass) < fields_count) {
3201+
RCLASS_SET_MAX_IV_COUNT(klass, fields_count);
3202+
}
31983203
}
31993204
}
32003205

0 commit comments

Comments
 (0)