diff options
author | Koichi Sasada <[email protected]> | 2020-09-25 18:31:04 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2020-09-25 20:37:38 +0900 |
commit | caaa36b4e6d0d59f0aa21049c063b140aa5aae4f (patch) | |
tree | 51e95c8e7be7a1a1793ab02a4c9f3a2cf2e1867f /vm_insnhelper.c | |
parent | 890bc2cdde4097390f3b71dfeaa36dd92ee0afe2 (diff) |
prohibi method call by defined_method in other racotrs
We can not call a non-isolated Proc in multiple ractors.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3584
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 30177b7a19..3d2667dfa7 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2667,9 +2667,14 @@ vm_call_bmethod_body(rb_execution_context_t *ec, struct rb_calling_info *calling rb_proc_t *proc; VALUE val; const struct rb_callcache *cc = cd->cc; + const rb_callable_method_entry_t *cme = vm_cc_cme(cc); + + if (cme->def->body.bmethod.defined_ractor != rb_ec_ractor_ptr(ec)->self) { + rb_raise(rb_eRuntimeError, "defined in a different Ractor"); + } /* control block frame */ - GetProcPtr(vm_cc_cme(cc)->def->body.bmethod.proc, proc); + GetProcPtr(cme->def->body.bmethod.proc, proc); val = rb_vm_invoke_bmethod(ec, proc, calling->recv, calling->argc, argv, calling->kw_splat, calling->block_handler, vm_cc_cme(cc)); return val; |