summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2023-07-17 09:50:10 +0900
committernagachika <nagachika@ruby-lang.org>2023-07-17 09:50:10 +0900
commit98b4ac7287928c202c90e9de1ae02c0707ec68b8 (patch)
treefb5a437a80a00d76c8e3f2aa509ee8418406a86d /vm_method.c
parentcb8d656100659eaee44042ca680886c30892df04 (diff)
merge revision(s) 537183cd2ac0163851277b46a2f21ea5914c11c0: [Backport #19577]
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 --- vm_eval.c | 3 +-- vm_insnhelper.c | 10 ++++++---- vm_method.c | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-)
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/vm_method.c b/vm_method.c
index 30241cc9cd..5f7264a53b 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1330,8 +1330,7 @@ cache_callable_method_entry(VALUE klass, ID mid, const rb_callable_method_entry_
VM_ASSERT(ccs->cme == cme);
}
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);
}
}