From f054f11a38f66af17a0aed8e0d2d46731eaab27d Mon Sep 17 00:00:00 2001 From: 卜部昌平 Date: Tue, 17 Dec 2019 15:49:41 +0900 Subject: per-method serial number Methods and their definitions can be allocated/deallocated on-the-fly. One pathological situation is when a method is deallocated then another one is allocated immediately after that. Address of those old/new method entries/definitions can be the same then, depending on underlying malloc/free implementation. So pointer comparison is insufficient. We have to check the contents. To do so we introduce def->method_serial, which is an integer unique to that specific method definition. PS: Note that method_serial being uintptr_t rather than rb_serial_t is intentional. This is because rb_serial_t can be bigger than a pointer on a 32bit system (rb_serial_t is at least 64bit). In order to preserve old packing of struct rb_call_cache, rb_serial_t is inappropriate. --- vm_eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vm_eval.c') diff --git a/vm_eval.c b/vm_eval.c index cec1ea41f6..54a4036ae7 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -47,7 +47,7 @@ rb_vm_call0(rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE { struct rb_calling_info calling = { Qundef, recv, argc, kw_splat, }; struct rb_call_info ci = { id, (kw_splat ? VM_CALL_KW_SPLAT : 0), argc, }; - struct rb_call_cache cc = { 0, { 0, }, me, me->def, vm_call_general, { 0, }, }; + struct rb_call_cache cc = { 0, { 0, }, me, me->def->method_serial, vm_call_general, { 0, }, }; struct rb_call_data cd = { cc, ci, }; return vm_call0_body(ec, &calling, &cd, argv); } -- cgit v1.2.3