Issue #5912 has been updated by ko1 (Koichi Sasada).

Category set to core
Status changed from Assigned to Closed
Target version set to 2.0.0

Close this ticket because I can't reproduce it on trunk (2.0).

Please re-open if you can reproduce this issue.

----------------------------------------
Bug #5912: Interpreter crashes when trying to invoke implicit block via Binding#eval
https://bugs.ruby-lang.org/issues/5912#change-31956

Author: ryanlecompte (Ryan LeCompte)
Status: Closed
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 2.0.0
ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.1]


Here's how to reproduce the problem:

[1] pry(main)> def foo
[1] pry(main)*   binding
[1] pry(main)* end  
=> nil
[2] pry(main)> b = foo { puts 'hi!' }
=> #<Binding:0x007f8b7a0e2ec0>
[3] pry(main)> b.eval('Proc.new').call
(pry):5: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.1]

-- control frame ----------
c:0020 p:---- s:0071 b:0071 l:000070 d:000070 CFUNC  :call
c:0019 p:0019 s:0068 b:0068 l:000fc8 d:001bc8 EVAL   (pry):5
c:0018 p:---- s:0066 b:0066 l:000065 d:000065 FINISH
c:0017 p:---- s:0064 b:0064 l:000063 d:000063 CFUNC  :eval
c:0016 p:0223 s:0058 b:0057 l:000056 d:000056 METHOD /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:235
c:0015 p:0041 s:0049 b:0049 l:000048 d:000048 METHOD /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:202
c:0014 p:0022 s:0044 b:0044 l:000028 d:000043 BLOCK  /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:187
c:0013 p:---- s:0042 b:0042 l:000041 d:000041 FINISH
c:0012 p:---- s:0040 b:0040 l:000039 d:000039 CFUNC  :loop
c:0011 p:0009 s:0037 b:0037 l:000028 d:000036 BLOCK  /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:186
c:0010 p:---- s:0035 b:0035 l:000034 d:000034 FINISH
c:0009 p:---- s:0033 b:0033 l:000032 d:000032 CFUNC  :catch
c:0008 p:0067 s:0029 b:0029 l:000028 d:000028 METHOD /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:185
c:0007 p:0188 s:0023 b:0023 l:001858 d:001858 METHOD /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_class.rb:97
c:0006 p:0164 s:0018 b:0018 l:000e60 d:000e60 TOP    /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/bin/pry:93
c:0005 p:---- s:0013 b:0013 l:000012 d:000012 FINISH
c:0004 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC  :load
c:0003 p:0127 s:0007 b:0007 l:000fc8 d:000270 EVAL   /Users/ryan/.rvm/gems/ruby-1.9.2-p290/bin/pry:19
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000fc8 d:000fc8 TOP   
---------------------------
-- Ruby level backtrace information ----------------------------------------
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/bin/pry:19:in `<main>'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/bin/pry:19:in `load'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/bin/pry:93:in `<top (required)>'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_class.rb:97:in `start'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:185:in `repl'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:185:in `catch'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:186:in `block in repl'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:186:in `loop'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:187:in `block (2 levels) in repl'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:202:in `rep'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:235:in `re'
/Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pry-0.9.7.4/lib/pry/pry_instance.rb:235:in `eval'
(pry):5:in `<main>'
(pry):5:in `call'

-- 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: 6

Interestingly enough, if you type it all on a single line, it works!

def foo; binding; end; b = foo { puts 'hi!' }; b.eval('Proc.new').call

But then afterwards, if you type:

b.eval('Proc.new').call

It will crash the interpreter.




-- 
http://bugs.ruby-lang.org/