8000 Fix missing write barrier on class fields · jeremyevans/ruby@912edb4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 912edb4

Browse files
committed
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
1 parent bfb14c2 commit 912edb4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

variable.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4726,7 +4726,12 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
47264726
// so that we're embedded as long as possible.
47274727
fields_obj = rb_imemo_fields_new(rb_singleton_class(klass), next_capacity);
47284728
if (original_fields_obj) {
4729-
MEMCPY(rb_imemo_fields_ptr(fields_obj), rb_imemo_fields_ptr(original_fields_obj), VALUE, RSHAPE_LEN(current_shape_id));
4729+
VALUE *fields = rb_imemo_fields_ptr(fields_obj);
4730+
attr_index_t fields_count = RSHAPE_LEN(current_shape_id);
4731+
MEMCPY(fields, rb_imemo_fields_ptr(original_fields_obj), VALUE, fields_count);
4732+
for (attr_index_t i = 0; i < fields_count; i++) {
4733+
RB_OBJ_WRITTEN(fields_obj, Qundef, fields[i]);
4734+
}
47304735
}
47314736
}
47324737

0 commit comments

Comments
 (0)
0