Skip to content

Commit e1081f3

Browse files
jhawthornk0kubun
authored andcommitted
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.
1 parent ff124e9 commit e1081f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

marshal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,14 @@ rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE),
143143

144144
compat_allocator_table();
145145
compat = ALLOC(marshal_compat_t);
146-
RB_OBJ_WRITE(compat_allocator_tbl_wrapper, &compat->newclass, newclass);
147-
RB_OBJ_WRITE(compat_allocator_tbl_wrapper, &compat->oldclass, oldclass);
146+
compat->newclass = newclass;
147+
compat->oldclass = oldclass;
148148
compat->dumper = dumper;
149149
compat->loader = loader;
150150

151151
st_insert(compat_allocator_table(), (st_data_t)allocator, (st_data_t)compat);
152+
RB_OBJ_WRITTEN(compat_allocator_tbl_wrapper, Qundef, newclass);
153+
RB_OBJ_WRITTEN(compat_allocator_tbl_wrapper, Qundef, oldclass);
152154
}
153155

154156
struct dump_arg {

0 commit comments

Comments
 (0)