Project

General

Profile

Bug #9063

irb crashes when #backtrace of raised Exception is nil

Added by Shimpei Makimoto about 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
ruby -v:
ruby 2.1.0dev (2013-10-30 trunk 43474) [x86_64-darwin13.0.0]
[ruby-core:58078]

Description

=begin
See also the pull req on GitHub: https://github.com/ruby/ruby/pull/434

When an exception whose backtrace is nil is raised, irb crashes and exits with the following backtrace:

irb> class E < Exception; def backtrace; nil; end; end
irb> raise E
E: E
/Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb.rb:502:in block (2 levels) in eval_input': undefined method[]' for nil:NilClass (NoMethodError)
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb.rb:624:in signal_status'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb.rb:489:in
block in eval_input'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb/ruby-lex.rb:247:in block (2 levels) in each_top_level_statement'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb/ruby-lex.rb:233:in
loop'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb/ruby-lex.rb:233:in block in each_top_level_statement'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb/ruby-lex.rb:232:in
catch'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb/ruby-lex.rb:232:in each_top_level_statement'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb.rb:488:in
eval_input'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb.rb:397:in block in start'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb.rb:396:in
catch'
from /Users/makimoto/.rbenv/versions/trunk/lib/ruby/2.1.0/irb.rb:396:in start'
from /Users/makimoto/.rbenv/versions/trunk/bin/irb:11:in
'

=end

irb-when-backtrace-nil.patch View (2.91 KB) Shimpei Makimoto, 10/31/2013 07:27 AM

Associated revisions

Revision 47164
Added by Hiroshi SHIBATA over 2 years ago

  • lib/irb.rb: Prevent irb from crashing when exception with nil backtrace is raised. [fix GH-434][Bug #9063]
  • test/irb/test_raise_no_backtrace_exception.rb: ditto.

Revision 47164
Added by Hiroshi SHIBATA over 2 years ago

  • lib/irb.rb: Prevent irb from crashing when exception with nil backtrace is raised. [fix GH-434][Bug #9063]
  • test/irb/test_raise_no_backtrace_exception.rb: ditto.

Revision 47164
Added by Hiroshi SHIBATA over 2 years ago

  • lib/irb.rb: Prevent irb from crashing when exception with nil backtrace is raised. [fix GH-434][Bug #9063]
  • test/irb/test_raise_no_backtrace_exception.rb: ditto.

History

#1 [ruby-core:58079] Updated by sorah Shota Fukumori about 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to Keiju Ishitsuka

+1, I think irb shouldn't die even if caught Exception is something wrong.

Could you attach a patch for here too?

#4 [ruby-core:64343] Updated by Hiroshi SHIBATA over 2 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Applied in changeset r47164.


  • lib/irb.rb: Prevent irb from crashing when exception with nil backtrace is raised. [fix GH-434][Bug #9063]
  • test/irb/test_raise_no_backtrace_exception.rb: ditto.

Also available in: Atom PDF