Skip to content

Commit c6a6645

Browse files
committed
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 a7dc515 commit c6a6645

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
@@ -145,12 +145,14 @@ rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE),
145145

146146
compat_allocator_table();
147147
compat = ALLOC(marshal_compat_t);
148-
RB_OBJ_WRITE(compat_allocator_tbl_wrapper, &compat->newclass, newclass);
149-
RB_OBJ_WRITE(compat_allocator_tbl_wrapper, &compat->oldclass, oldclass);
148+
compat->newclass = newclass;
149+
compat->oldclass = oldclass;
150150
compat->dumper = dumper;
151151
compat->loader = loader;
152152

153153
st_insert(compat_allocator_table(), (st_data_t)allocator, (st_data_t)compat);
154+
RB_OBJ_WRITTEN(compat_allocator_tbl_wrapper, Qundef, newclass);
155+
RB_OBJ_WRITTEN(compat_allocator_tbl_wrapper, Qundef, oldclass);
154156
}
155157

156158
struct dump_arg {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy