Project

General

Profile

Bug #12018

Tail call optimization is incorrectly applied in Ruby 2.3.0

Added by rhenium (Kazuki Yamaguchi) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-01-25 trunk 53652) [x86_64-linux]
[ruby-core:73413]

Description

r51903 changed the operand order of send/invokesuper instructions, but the code applying tail call optimization still looks at the second operand, which is now CALL_CACHE.
The following code causes a segmentation fault:

RubyVM::InstructionSequence.compile_option = { tailcall_optimization: true }

def just_yield
  yield
end

eval "just_yield { }"

I attached a patch to fix it.


Files

#1

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Status changed from Open to Closed

Applied in changeset r53658.


compile.c: fix tailcall optimization

  • compile.c (iseq_peephole_optimize): don't apply tailcall optimization to send/invokesuper instructions with blockiseq. This is a follow-up to the changes in r51903; blockiseq is now the third operand of send/invokesuper instructions. [ruby-core:73413] [Bug #12018]

Updated by nagachika (Tomoyuki Chikanaga) over 4 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED

Updated by naruse (Yui NARUSE) over 4 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE

ruby_2_3 r54401 merged revision(s) 53658.

Also available in: Atom PDF