ruby-changes:61466
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Wed, 3 Jun 2020 16:14:14 +0900 (JST)
Subject: [ruby-changes:61466] de5e0f7c06 (master): vm_invoke_proc_block: reduce recursion
https://git.ruby-lang.org/ruby.git/commit/?id=de5e0f7c06 From de5e0f7c0671323820c4eb9b5a11c90a26c3dad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Sun, 31 May 2020 17:34:58 +0900 Subject: vm_invoke_proc_block: reduce recursion According to nobu recursion can be longer than my expectation. Limit them here. diff --git a/vm_insnhelper.c b/vm_insnhelper.c index bd6b0a2..6c82d74 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -3517,11 +3517,15 @@ vm_proc_to_block_handler(VALUE procval) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3517 static VALUE vm_invoke_proc_block(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb_calling_info *calling, const struct rb_callinfo *ci, - MAYBE_UNUSED(bool is_lambda), VALUE block_handler) + bool is_lambda, VALUE block_handler) { - return vm_invoke_block(ec, reg_cfp, calling, ci, - block_proc_is_lambda(VM_BH_TO_PROC(block_handler)), - vm_proc_to_block_handler(VM_BH_TO_PROC(block_handler))); + while (vm_block_handler_type(block_handler) == block_handler_type_proc) { + VALUE proc = VM_BH_TO_PROC(block_handler); + is_lambda = block_proc_is_lambda(proc); + block_handler = vm_proc_to_block_handler(proc); + } + + return vm_invoke_block(ec, reg_cfp, calling, ci, is_lambda, block_handler); } static inline VALUE -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/