Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure all inspection exception are gracefully handled #376

Merged
merged 2 commits into from
Nov 9, 2021

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Nov 9, 2021

Currently, if we evaluate an object with issue in its #inspect method, it'll crash the debugger:

(rdbg) foo
["DEBUGGER Exception: /Users/st0012/projects/debug/lib/debug/thread_client.rb:970",
 #<RuntimeError: foo>,
 ["target.rb:4:in `inspect'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/pp.rb:304:in `pretty_print'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/pp.rb:177:in `block in pp'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:253:in `block (2 levels) in group'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:280:in `nest'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:252:in `block in group'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:265:in `group_sub'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:251:in `group'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/pp.rb:177:in `pp'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/lib/irb/color_printer.rb:29:in `pp'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/lib/irb/color_printer.rb:10:in `block in pp'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/pp.rb:134:in `guard_inspect_key'",
  "/Users/st0012/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/lib/irb/color_printer.rb:10:in `pp'",
  "/Users/st0012/projects/debug/lib/debug/color.rb:52:in `color_pp'",
  "/Users/st0012/projects/debug/lib/debug/thread_client.rb:781:in `wait_next_action_'",
  "/Users/st0012/projects/debug/lib/debug/thread_client.rb:660:in `wait_next_action'",
  "/Users/st0012/projects/debug/lib/debug/thread_client.rb:280:in `suspend'",
  "/Users/st0012/projects/debug/lib/debug/thread_client.rb:218:in `on_breakpoint'",
  "/Users/st0012/projects/debug/lib/debug/breakpoint.rb:63:in `suspend'",
  "/Users/st0012/projects/debug/lib/debug/breakpoint.rb:147:in `block in setup'",
  "/Users/st0012/projects/debug/lib/debug/session.rb:2157:in `debugger'",
  "target.rb:33:in `<main>'"]]
target.rb:4:in `inspect': foo (RuntimeError)
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/pp.rb:304:in `pretty_print'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/pp.rb:177:in `block in pp'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:253:in `block (2 levels) in group'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:280:in `nest'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:252:in `block in group'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:265:in `group_sub'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/prettyprint.rb:251:in `group'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/pp.rb:177:in `pp'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/lib/irb/color_printer.rb:29:in `pp'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/lib/irb/color_printer.rb:10:in `block in pp'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/3.0.0/pp.rb:134:in `guard_inspect_key'
        from /Users/st0012/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/lib/irb/color_printer.rb:10:in `pp'
        from /Users/st0012/projects/debug/lib/debug/color.rb:52:in `color_pp'
        from /Users/st0012/projects/debug/lib/debug/thread_client.rb:781:in `wait_next_action_'
        from /Users/st0012/projects/debug/lib/debug/thread_client.rb:660:in `wait_next_action'
        from /Users/st0012/projects/debug/lib/debug/thread_client.rb:280:in `suspend'
        from /Users/st0012/projects/debug/lib/debug/thread_client.rb:218:in `on_breakpoint'
        from /Users/st0012/projects/debug/lib/debug/breakpoint.rb:63:in `suspend'
        from /Users/st0012/projects/debug/lib/debug/breakpoint.rb:147:in `block in setup'
        from /Users/st0012/projects/debug/lib/debug/session.rb:2157:in `debugger'
        from target.rb:33:in `<main>'

This PR fixes the issue:

(rdbg) foo
#<RuntimeError: foo> rescued during inspection
(rdbg)

lib/debug/color.rb Outdated Show resolved Hide resolved
Co-authored-by: Koichi Sasada <ko1@atdot.net>
@st0012 st0012 requested a review from ko1 November 9, 2021 17:13
@ko1 ko1 merged commit 0ac2240 into ruby:master Nov 9, 2021
@st0012 st0012 deleted the fix-inspection-error-on-pp branch November 10, 2021 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants