Skip to content

Commit 78e8594

Browse files
committed
Fix missing write barrier through M_TBL
When creating a new origin in ensure_origin, we need to fire a write barrier after RCLASS_SET_ORIGIN. rb_class_set_super allocates, so GC could happen there, either incrementally marking or promoting the newly allocated class, and only after RCLASS_SET_ORIGIN will origin mark object in the M_TBL.
1 parent 07f7832 commit 78e8594

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

class.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,11 @@ ensure_origin(VALUE klass)
14281428
RCLASS_SET_SUPER(origin, RCLASS_SUPER(klass));
14291429
RCLASS_SET_SUPER(klass, origin);
14301430
RCLASS_SET_ORIGIN(klass, origin);
1431+
1432+
// RCLASS_SET_ORIGIN marks origin as an origin, so this is the first
1433+
// point that it sees M_TBL and may mark it
1434+
rb_gc_writebarrier_remember(origin);
1435+
14311436
RCLASS_M_TBL_INIT(klass);
14321437
rb_id_table_foreach(RCLASS_M_TBL(origin), cache_clear_refined_method, (void *)klass);
14331438
rb_id_table_foreach(RCLASS_M_TBL(origin), move_refined_method, (void *)klass);

0 commit comments

Comments
 (0)