-
Notifications
You must be signed in to change notification settings - Fork 138
Closed
Milestone
Description
Your environment
ruby -v
:ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin21]
rdbg -v
:1.5.0
Description
I spotted a weird behavior when using catch Exception
or catch StandardError
and then causing an exception in the console. Example:
❯ exe/rdbg -e "catch Exception do: 'debugger spotted an error' ;; raise 'foo' ;; " target.rb
[1, 1] in target.rb
=> 1| puts(123)
=>#0 <main> at target.rb:1
(rdbg:commands) catch Exception do: 'debugger spotted an error'
#0 BP - Catch "Exception"
(rdbg:commands) raise 'foo'
[1, 1] in (rdbg)/target.rb
=> 1| raise 'foo'
=>#0 <main> at (rdbg)/target.rb:1
#1 [C] Binding#eval at ~/projects/debug/lib/debug/thread_client.rb:369
# and 2 frames (use `bt' command for all frames)
Stop by #0 BP - Catch "Exception"
(rdbg:catch) 'debugger spotted an error'
"debugger spotted an error"
eval error: foo
(rdbg)/target.rb:1:in `<main>'
nil
# catch breakpoint is triggered and performed command as expected, so far so good.
# let's run some other commands
(rdbg) ls # outline command
Object.methods: inspect to_s
# for some reason, the catch bp's command is triggered again
(rdbg:catch) 'debugger spotted an error'
"debugger spotted an error"
# and it exits the current bp for no apparent reason
123
Reproduction
Scripit
puts(123)
Command and output
$ exe/rdbg -e "catch Exception do: 'debugger spotted an error' ;; raise 'foo' ;; " target.rb
- Run arbitrary debugger command, like
ls
Expected Behavior
- The
'debugger spotted an error'
message is only printed once. - The arbitrary command doesn't exit the debugging session.
Actual Behavior
- The
do:
command is executed for the second time when no new exception is raised. - When 1 happens, it also tries to leave the current debugging session without being told to do so.
However, if we use a more specific exception name, like catch RuntimeError
, neither the problem occurs.
Therefore, I suspect that debugger has some internal exceptions happening between step 1 and 2, which triggered the catch breakpoint unexpectedly.
Metadata
Metadata
Assignees
Labels
No labels