From: shugo@... Date: 2016-07-10T00:49:55+00:00 Subject: [ruby-core:76330] [Ruby trunk Bug#12576][Assigned] SEGV when interrupting tail recursion Issue #12576 has been updated by Shugo Maeda. Status changed from Open to Assigned Assignee set to Koichi Sasada SEGV occurs as follows: 1. eval pushes a control frame. 2. foo is called repeatedly without a new control frame. 3. Interrupted by a signal, and the exception handler of eval pops the control frame pushed by Step 1. OVER POP! 4. The main exception handler pops the bottom control frame. 5. vm_push_frame() is called by error_print(), and it causes SEGV. The following patch seems to fix the problem, but I'm not sure. Could you check it, ko1? ```diff diff --git a/compile.c b/compile.c index 33e0ba3..c2a710a 100644 --- a/compile.c +++ b/compile.c @@ -2415,6 +2415,8 @@ static inline int tailcallable_p(rb_iseq_t *iseq) { switch (iseq->body->type) { + case ISEQ_TYPE_EVAL: + /* eval can't tail call because cfp will be over popped */ case ISEQ_TYPE_RESCUE: case ISEQ_TYPE_ENSURE: /* rescue block can't tail call because of errinfo */ ``` ---------------------------------------- Bug #12576: SEGV when interrupting tail recursion https://bugs.ruby-lang.org/issues/12576#change-59565 * Author: Shugo Maeda * Status: Assigned * Priority: Normal * Assignee: Koichi Sasada * ruby -v: * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- The following program causes SEGV when interrupted by SIGINT. ```ruby RubyVM::InstructionSequence.compile_option = { :tailcall_optimization => true, :trace_instruction => false } eval <