aboutsummaryrefslogtreecommitdiffstats
path: root/vm_eval.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2023-01-12 13:30:06 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2023-01-12 15:18:18 -0500
commit537183cd2ac0163851277b46a2f21ea5914c11c0 (patch)
tree8048674b59ff157bf48c4390b6e72bbad9a3d200 /vm_eval.c
parentda7e5c7b776e8ebbbef97c15305fbad5d032242b (diff)
downloadruby-537183cd2ac0163851277b46a2f21ea5914c11c0.tar.gz
Fix write barrier order for `klass` to `cme` edge
Previously, the following crashes with `CFLAGS=-DRGENGC_CHECK_MODE=2 -DRUBY_DEBUG=1 -fno-inline`: $ ./miniruby -e 'GC.stress = true; Marshal.dump({})' It crashes with a write barrier (WB) miss assertion on an edge from the `Hash` class object to a newly allocated negative method entry. This is due to usages of vm_ccs_create() running the WB too early, before the method entry is inserted into the cc table, so before the reference edge is established. The insertion can trigger GC and promote the class object, so running the WB after the insertion is necessary. Move the insertion into vm_ccs_create() and run the WB after the insertion. Discovered on CI: http://ci.rvm.jp/results/trunk-asserts@ruby-sp2-docker/4391770
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/vm_eval.c b/vm_eval.c
index f219e7037b..1caa76000b 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -396,8 +396,7 @@ cc_new(VALUE klass, ID mid, int argc, const rb_callable_method_entry_t *cme)
ccs = (struct rb_class_cc_entries *)ccs_data;
}
else {
- ccs = vm_ccs_create(klass, cme);
- rb_id_table_insert(cc_tbl, mid, (VALUE)ccs);
+ ccs = vm_ccs_create(klass, cc_tbl, mid, cme);
}
for (int i=0; i<ccs->len; i++) {