Bug #4881
closedsuper() in define_method which returns proc causes SEGV
Description
In working through some corner cases, we ran across (https://gist.github.com/1023643):
class Base
def foo
puts "Base foo"
end
def bar
puts "Base bar"
end
end
class Derived < Base
def bar
self.class.send(:define_method, :foo) do
proc { super() }
end
end
end
d = Derived.new
code = d.bar
d.foo.call
And this ends up generating a SEGV:
ruby super2.rb
super2.rb:15: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
-- control frame ----------
c:0006 p:0008 s:0016 b:0015 l:000a18 d:000014 BLOCK super2.rb:15
c:0005 p:---- s:0013 b:0013 l:000012 d:000012 FINISH
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC :call
c:0003 p:0075 s:0008 b:0008 l:0014f8 d:0003c8 EVAL super2.rb:22
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0014f8 d:0014f8 TOP
-- Ruby level backtrace information ----------------------------------------
super2.rb:22:in <main>' super2.rb:22:in
call'
super2.rb:15:in `block (2 levels) in bar'
-- 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
This should print out that it is calling foo in the base class.
Files