mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
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.
This commit is contained in:
parent
879f4886c9
commit
00357eea31
1 changed files with 4 additions and 0 deletions
|
@ -4704,6 +4704,10 @@ class_fields_ivar_set(VALUE klass, VALUE fields_obj, ID id, VALUE val, bool conc
|
||||||
|
|
||||||
too_complex:
|
too_complex:
|
||||||
{
|
{
|
||||||
|
if (concurrent && fields_obj == original_fields_obj) {
|
||||||
|
// If we're in the multi-ractor mode, we can't directly insert in the table.
|
||||||
|
fields_obj = rb_imemo_fields_clone(fields_obj);
|
||||||
|
}
|
||||||
st_table *table = rb_imemo_fields_complex_tbl(fields_obj);
|
st_table *table = rb_imemo_fields_complex_tbl(fields_obj);
|
||||||
existing = st_insert(table, (st_data_t)id, (st_data_t)val);
|
existing = st_insert(table, (st_data_t)id, (st_data_t)val);
|
||||||
RB_OBJ_WRITTEN(fields_obj, Qundef, val);
|
RB_OBJ_WRITTEN(fields_obj, Qundef, val);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue