summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2025-06-18 16:52:27 -0700
committerJohn Hawthorn <[email protected]>2025-06-18 20:54:01 -0700
commit912edb47162626bf039ee649c8a1d05b2d7410ef (patch)
tree9ef8fb0b05ca1612ab283dc9dd3891551eafcb73
parentbfb14c2be91735d5cdd2b5cefe7f19d46a5b4f4a (diff)
Fix missing write barrier on class fields
Found by wbcheck klass = Class.new 200.times do |iv| klass.instance_variable_set("@_iv_#{iv}", Object.new) end
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13654
-rw-r--r--variable.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/variable.c b/variable.c
index e535aefe27..a2012823cd 100644
--- a/variable.c
+++ b/variable.c
@@ -4726,7 +4726,12 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
// so that we're embedded as long as possible.
fields_obj = rb_imemo_fields_new(rb_singleton_class(klass), next_capacity);
if (original_fields_obj) {
- MEMCPY(rb_imemo_fields_ptr(fields_obj), rb_imemo_fields_ptr(original_fields_obj), VALUE, RSHAPE_LEN(current_shape_id));
+ VALUE *fields = rb_imemo_fields_ptr(fields_obj);
+ attr_index_t fields_count = RSHAPE_LEN(current_shape_id);
+ MEMCPY(fields, rb_imemo_fields_ptr(original_fields_obj), VALUE, fields_count);
+ for (attr_index_t i = 0; i < fields_count; i++) {
+ RB_OBJ_WRITTEN(fields_obj, Qundef, fields[i]);
+ }
}
}