Skip to content

Commit 00357ee

Browse files
committed
class_fields_ivar_set: fix multi-ractor mode
We must copy the table before inserting into it if we're in multi-ractor mode to ensure the table won't be rehashed or resized.
1 parent 879f488 commit 00357ee

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

variable.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4704,6 +4704,10 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
47044704

47054705
too_complex:
47064706
{
4707+
if (concurrent && fields_obj == original_fields_obj) {
4708+
// If we're in the multi-ractor mode, we can't directly insert in the table.
4709+
fields_obj = rb_imemo_fields_clone(fields_obj);
4710+
}
47074711
st_table *table = rb_imemo_fields_complex_tbl(fields_obj);
47084712
existing = st_insert(table, (st_data_t)id, (st_data_t)val);
47094713
RB_OBJ_WRITTEN(fields_obj, Qundef, val);

0 commit comments

Comments
 (0)