summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatoshi Tagomori <tagomoris@gmail.com>2025-05-11 00:39:53 +0900
committerSatoshi Tagomori <tagomoris@gmail.com>2025-05-11 23:32:50 +0900
commitbbcc3782b11939075f753b8f3260c8cd5137d600 (patch)
tree01dfa662e64a12b0ab0f0aee45796e506113fa4b
parentc2c5b0542324a0c74e033bbe79a65caf2204ed95 (diff)
Skip updating max_iv_count when the namespace cannot be determined
-rw-r--r--gc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gc.c b/gc.c
index edb78a1923..302b95f664 100644
--- a/gc.c
+++ b/gc.c
@@ -3192,9 +3192,14 @@ rb_gc_mark_children(void *objspace, VALUE obj)
if (fields_count) {
VALUE klass = RBASIC_CLASS(obj);
- // Increment max_iv_count if applicable, used to determine size pool allocation
- if (RCLASS_MAX_IV_COUNT(klass) < fields_count) {
- RCLASS_WRITE_MAX_IV_COUNT(klass, fields_count);
+ // Skip updating max_iv_count if the prime classext is not writable
+ // because GC context doesn't provide information about namespaces.
+ if (RCLASS_PRIME_CLASSEXT_WRITABLE_P(klass)) {
+ VM_ASSERT(rb_shape_obj_too_complex_p(klass));
+ // Increment max_iv_count if applicable, used to determine size pool allocation
+ if (RCLASS_MAX_IV_COUNT(klass) < fields_count) {
+ RCLASS_SET_MAX_IV_COUNT(klass, fields_count);
+ }
}
}