Fix early write barrier rb_marshal_define_compat

This write barrier occurred before the entry was added to the table, so
if GC occurred when inserting into the table, the write could be missed.
This commit is contained in:
John Hawthorn 2025-06-10 11:15:47 -07:00
parent a7dc515c1d
commit c6a6645495
Notes: git 2025-06-17 22:33:32 +00:00

View File

@ -145,12 +145,14 @@ rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE),
compat_allocator_table();
compat = ALLOC(marshal_compat_t);
RB_OBJ_WRITE(compat_allocator_tbl_wrapper, &compat->newclass, newclass);
RB_OBJ_WRITE(compat_allocator_tbl_wrapper, &compat->oldclass, oldclass);
compat->newclass = newclass;
compat->oldclass = oldclass;
compat->dumper = dumper;
compat->loader = loader;
st_insert(compat_allocator_table(), (st_data_t)allocator, (st_data_t)compat);
RB_OBJ_WRITTEN(compat_allocator_tbl_wrapper, Qundef, newclass);
RB_OBJ_WRITTEN(compat_allocator_tbl_wrapper, Qundef, oldclass);
}
struct dump_arg {