mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Fix missing write barrier through M_TBL
When creating a new origin in ensure_origin, we need to fire a write barrier after RCLASS_WRITE_ORIGIN. rb_class_set_super allocates, so GC could happen there, either incrementally marking or promoting the newly allocated class, and only after RCLASS_WRITE_ORIGIN will origin mark object in the M_TBL.
This commit is contained in:
parent
54a578e72a
commit
d67eb07f75
1 changed files with 5 additions and 0 deletions
5
class.c
5
class.c
|
@ -1931,6 +1931,11 @@ ensure_origin(VALUE klass)
|
||||||
rb_class_set_super(origin, RCLASS_SUPER(klass));
|
rb_class_set_super(origin, RCLASS_SUPER(klass));
|
||||||
rb_class_set_super(klass, origin); // writes origin into RCLASS_SUPER(klass)
|
rb_class_set_super(klass, origin); // writes origin into RCLASS_SUPER(klass)
|
||||||
RCLASS_WRITE_ORIGIN(klass, origin);
|
RCLASS_WRITE_ORIGIN(klass, origin);
|
||||||
|
|
||||||
|
// RCLASS_WRITE_ORIGIN marks origin as an origin, so this is the first
|
||||||
|
// point that it sees M_TBL and may mark it
|
||||||
|
rb_gc_writebarrier_remember(origin);
|
||||||
|
|
||||||
class_clear_method_table(klass);
|
class_clear_method_table(klass);
|
||||||
rb_id_table_foreach(RCLASS_M_TBL(origin), cache_clear_refined_method, (void *)klass);
|
rb_id_table_foreach(RCLASS_M_TBL(origin), cache_clear_refined_method, (void *)klass);
|
||||||
rb_id_table_foreach(RCLASS_M_TBL(origin), move_refined_method, (void *)klass);
|
rb_id_table_foreach(RCLASS_M_TBL(origin), move_refined_method, (void *)klass);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue