Actions
Backport #4082
closedSegfault with tailcall_optimization and class definition
Status:
Closed
Assignee:
Description
=begin
Code:
RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}
RubyVM::InstructionSequence.new(<<-EOF).eval
class Foo
def fact_helper(n, res)
if n == 1
res
else
fact_helper(n - 1, n * res)
end
end
def fact(n)
fact_helper(n, 1)
end
end
EOF
p Foo.new.fact(30000)
Error:
<compiled>:6: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
-- control frame ----------
c:0004 p:0031 s:0014 b:0011 l:000010 d:000010 METHOD <compiled>:6
c:0003 p:0078 s:0007 b:0006 l:001588 d:001e68 EVAL -:22
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001588 d:001588 TOP
---------------------------
-- Ruby level backtrace information ----------------------------------------
-:22:in `<main>'
<compiled>:6:in `fact_helper'
-- C level backtrace information -------------------------------------------
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
Abort trap
=end
Actions
Like0
Like0Like0Like0Like0