Forum: Ruby-core [ruby-trunk - Bug #9063][Open] irb crashes when #backtrace of raised Exception is nil

75aa7ede4ef862d25c68133c64860c4a?d=identicon&s=25 makimoto (Shimpei Makimoto) (Guest)
on 2013-10-30 17:05
(Received via mailing list)
Issue #9063 has been reported by makimoto (Shimpei Makimoto).

----------------------------------------
Bug #9063: irb crashes when #backtrace of raised Exception is nil
https://bugs.ruby-lang.org/issues/9063

Author: makimoto (Shimpei Makimoto)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 2.1.0dev (2013-10-30 trunk 43474) [x86_64-darwin13.0.0]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


=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 `<main>'

=end
C4f076f658dd3464f1d8785ad53a0d99?d=identicon&s=25 sorah (Shota Fukumori) (Guest)
on 2013-10-30 17:38
(Received via mailing list)
Issue #9063 has been updated by sorah (Shota Fukumori).

Status changed from Open to Assigned
Assignee set to keiju (Keiju Ishitsuka)

Could you attach a patch for here too?

IMO, I think irb shouldn't die even if caught Exception is something
wrong.
----------------------------------------
Bug #9063: irb crashes when #backtrace of raised Exception is nil
https://bugs.ruby-lang.org/issues/9063#change-42659

Author: makimoto (Shimpei Makimoto)
Status: Assigned
Priority: Normal
Assignee: keiju (Keiju Ishitsuka)
Category:
Target version:
ruby -v: ruby 2.1.0dev (2013-10-30 trunk 43474) [x86_64-darwin13.0.0]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


=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 `<main>'

=end
75aa7ede4ef862d25c68133c64860c4a?d=identicon&s=25 makimoto (Shimpei Makimoto) (Guest)
on 2013-10-30 23:27
(Received via mailing list)
Issue #9063 has been updated by makimoto (Shimpei Makimoto).

File irb-when-backtrace-nil.patch added

attached a patch. (which is same with
https://github.com/ruby/ruby/pull/434.patch)
----------------------------------------
Bug #9063: irb crashes when #backtrace of raised Exception is nil
https://bugs.ruby-lang.org/issues/9063#change-42667

Author: makimoto (Shimpei Makimoto)
Status: Assigned
Priority: Normal
Assignee: keiju (Keiju Ishitsuka)
Category:
Target version:
ruby -v: ruby 2.1.0dev (2013-10-30 trunk 43474) [x86_64-darwin13.0.0]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


=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 `<main>'

=end
C4f076f658dd3464f1d8785ad53a0d99?d=identicon&s=25 sorah (Shota Fukumori) (Guest)
on 2013-11-27 06:47
(Received via mailing list)
Issue #9063 has been updated by sorah (Shota Fukumori).


ping?
----------------------------------------
Bug #9063: irb crashes when #backtrace of raised Exception is nil
https://bugs.ruby-lang.org/issues/9063#change-43196

Author: makimoto (Shimpei Makimoto)
Status: Assigned
Priority: Normal
Assignee: keiju (Keiju Ishitsuka)
Category:
Target version:
ruby -v: ruby 2.1.0dev (2013-10-30 trunk 43474) [x86_64-darwin13.0.0]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN


=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 `<main>'

=end
Eabad423977cfc6873b8f5df62b848a6?d=identicon&s=25 unknown (Guest)
on 2014-08-13 04:20
(Received via mailing list)
Issue #9063 has been updated by Hiroshi SHIBATA.

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][ruby-core:58078][Bug #9063]
* test/irb/test_raise_no_backtrace_exception.rb: ditto.

----------------------------------------
Bug #9063: irb crashes when #backtrace of raised Exception is nil
https://bugs.ruby-lang.org/issues/9063#change-48323

* Author: Shimpei Makimoto
* Status: Closed
* Priority: Normal
* Assignee: Keiju Ishitsuka
* Category:
* Target version:
* ruby -v: ruby 2.1.0dev (2013-10-30 trunk 43474) [x86_64-darwin13.0.0]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN
----------------------------------------
=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 `<main>'

=end

---Files--------------------------------
irb-when-backtrace-nil.patch (2.91 KB)
This topic is locked and can not be replied to.