`next` / `step` / `finish` are cancelled at a line whose breakpoint does not stop there (e.g. a false condition), and the program runs on
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 55/100
Direção de pesquisa
The report identifies ThreadClient#step_tp in lib/debug/thread_client.rb and Session#stop_stepping? in lib/debug/session.rb as the relevant paths, with breakpoint event and condition handling in lib/debug/breakpoint.rb. Read those checks alongside the behavior introduced by #784, then reproduce the listed next, step, and finish cases. Done means stepping completes as it does without the extra breakpoint, while breakpoints that do fire still stop execution.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
next, step and finish are cancelled when the step meets an event on a line that has a breakpoint, even when that breakpoint does not stop on that event (its condition is false, or it is bound to another event). Nothing stops the program after that: it runs to its end, or to the next breakpoint that does fire, possibly in a later call.
Your environment
ruby -v:ruby 4.0.10 (2026-11-19 revision a704b7cd95) +PRISM [x86_64-linux](officialruby:4.0Docker image); the same withruby 3.4.13 (2026-11-19 revision 48857d6f2e) +PRISM [x86_64-linux]; withruby 3.3.14every case but case 3 (below).rdbg -v:rdbg 1.11.1(gem install debug -v 1.11.1). Cases 1 to 3 also on Windows,ruby 3.4.9 [x64-mingw-ucrt]with debug 1.11.0.
To Reproduce
target.rb:
def calc(x)
a = x + 1
b = a + 1
c = b + 1
return c
end
def helper(x)
y = x * 2
y + 1
end
def run
n = $n
v = helper(n)
calc(v)
end
$n = 0
while $n < 3
puts "run #{$n} => #{run}"
$n += 1
end
Case 1, next onto a line whose breakpoint condition is false. Run from the directory of target.rb; the script has to be named by its absolute path (see the second details block):
rdbg --no-rc --no-color -e 'b 3 if: $n == 1' -e 'b 4 if: $n == 99' -e c -e next -e 'p $n' -e 'q!' "$PWD/target.rb"
Its output from the breakpoint stop on, and the same for the control run without -e 'b 4 if: $n == 99' (Ruby 4.0.10; [source listing] stands for the ten-line listing rdbg prints at a stop):
with b 4 if: $n == 99: the program runs to its end | control: next stops at line 4 |
|---|---|
|
|
Expected behavior
Each step completes where it does without the extra breakpoint. The other cases, same program, each stopped first in the call with $n == 1 (commands and output in the first details block):
| case | expected | actual |
|---|---|---|
1 with step instead of next |
stops at line 4, $n == 1 |
runs to the end |
2. next over helper(n) from line 15: b 15 if: $n == 1, b 10 if: $n == 99 |
stops at line 16 | runs to the end |
3. finish from return c: b 5 if: $n == 1 |
stops at the return of calc, #=> 6 (as it does when the breakpoint is deleted first) |
runs to the end; with an unconditional b 5, Stop by #0 on line 5 in the next call |
4. next from line 2: b 2 if: $n == 1 (reported as (call)), b 4 if: $n == 1 |
stops at line 3 | Stop by #1 on line 4; line 3 ran without a stop |
Additional context
The cause, read in v1.11.1 (master at 6510cfbc has the same lines):
- Every step command installs one TracePoint in
ThreadClient#step_tp, and its first act on every event istp.disablewhenSESSION.stop_stepping?is true: thread_client.rb#L344-L348. This comes before the step's own filter (#L349), so it also applies inside a call thatnextsteps over (case 2). Session#stop_stepping?is true whenever@bps.has_key? [file, line]: session.rb#L158-L166. Nothing asks whether that breakpoint will suspend on this event; a line breakpoint is a TracePoint for one event type, with its condition checked in its own hook (breakpoint.rb#L165-L181).- #784 (first released in v1.7.0) changed this line from
next if SESSION.break_at? tp.path, tp.lineno, which skipped this one event and kept stepping (v1.6.3 thread_client.rb#L334), intotp.disable, which ends the step.
#874 loses a next through the other half of the same check: debugger do: enters a subsession, and the changed subsession id cancels the step. Here no subsession is entered; the @bps.has_key? half cancels the step because a breakpoint exists on the line, whether or not it fires.
The other cases: commands and output (Ruby 4.0.10)
$ rdbg --no-rc --no-color -e 'b 3 if: $n == 1' -e 'b 4 if: $n == 99' -e c -e step -e 'p $n' -e 'q!' /tmp/repro/target.rb
Stop by #0 BP - Line /tmp/repro/target.rb:3 (line) if: $n == 1
(rdbg:commands) step
run 1 => 6
run 2 => 8
$ rdbg --no-rc --no-color -e 'b 15 if: $n == 1' -e 'b 10 if: $n == 99' -e c -e next -e 'p $n' -e 'q!' /tmp/repro/target.rb
Stop by #0 BP - Line /tmp/repro/target.rb:15 (line) if: $n == 1
(rdbg:commands) next
run 1 => 6
run 2 => 8
$ rdbg --no-rc --no-color -e 'b 5 if: $n == 1' -e c -e finish -e 'p $n' -e 'q!' /tmp/repro/target.rb
Stop by #0 BP - Line /tmp/repro/target.rb:5 (line) if: $n == 1
(rdbg:commands) finish
run 1 => 6
run 2 => 8
$ rdbg --no-rc --no-color -e 'b 5' -e c -e 'p $n' -e finish -e 'p $n' -e 'q!' /tmp/repro/target.rb
Stop by #0 BP - Line /tmp/repro/target.rb:5 (line)
(rdbg:commands) p $n
=> 0
(rdbg:commands) finish
run 0 => 4
[source listing]
=>#0 Object#calc(x=3) at /tmp/repro/target.rb:5
#1 Object#run at /tmp/repro/target.rb:16
# and 1 frames (use `bt' command for all frames)
Stop by #0 BP - Line /tmp/repro/target.rb:5 (line)
(rdbg:commands) p $n
=> 1
(rdbg:commands) q!
$ rdbg --no-rc --no-color -e 'b 2 if: $n == 1' -e 'b 4 if: $n == 1' -e c -e next -e 'p $n' -e 'q!' /tmp/repro/target.rb
Stop by #0 BP - Line /tmp/repro/target.rb:2 (call) if: $n == 1
(rdbg:commands) next
[source listing]
=>#0 Object#calc(x=3) at /tmp/repro/target.rb:4
#1 Object#run at /tmp/repro/target.rb:16
# and 1 frames (use `bt' command for all frames)
Stop by #1 BP - Line /tmp/repro/target.rb:4 (line) if: $n == 1
(rdbg:commands) p $n
=> 1
(rdbg:commands) q!
Spy on stop_stepping?, why the script path matters, Ruby 3.3
A spy loaded with -x spy.cmds before the -e commands:
eval DEBUGGER__::SESSION.singleton_class.prepend(Module.new { def stop_stepping?(f, l, s = nil); r = super; ks = @bps.keys.select { |k| k.is_a?(Array) && k[1] == l }; STDERR.puts "SPY stop_stepping?(#{f.inspect}, #{l}) => #{r}; breakpoint keys for line #{l}: #{ks.inspect}"; r; end })
It printed, right before the program ran on (or stopped at the second breakpoint in case 4):
case 1: SPY stop_stepping?("/tmp/w/target.rb", 4) => true; breakpoint keys for line 4: [["/tmp/w/target.rb", 4]]
case 2: SPY stop_stepping?("/tmp/w/target.rb", 9) => false; breakpoint keys for line 9: []
case 2: SPY stop_stepping?("/tmp/w/target.rb", 10) => true; breakpoint keys for line 10: [["/tmp/w/target.rb", 10]]
case 3: SPY stop_stepping?("/tmp/w/target.rb", 5) => true; breakpoint keys for line 5: [["/tmp/w/target.rb", 5]]
case 4: SPY stop_stepping?("/tmp/w/target.rb", 2) => true; breakpoint keys for line 2: [["/tmp/w/target.rb", 2]]
In case 4 the true is for line 2, the line the next was issued from, whose key belongs to the (call) breakpoint; in its control (no breakpoint on line 4) the first line asked about is line 3 (false), and next stops there.
The breakpoint's key is built from iseq.absolute_path (breakpoint.rb#L192-L194), and stop_stepping? is called with tp.path. Started as rdbg ... target.rb, case 1 stops at line 4, and the spy printed:
SPY stop_stepping?("target.rb", 4) => false; breakpoint keys for line 4: [["/tmp/w/target.rb", 4]]
Two more runs with that in mind:
- Relative path,
b 3,b 4(both unconditional),c,next:nextstops at line 4 as a step, andcthen stops at line 4 again (Stop by #1,$nstill 0). With the absolute path the same commands stop at line 4 once. - A file loaded with
require_relativeloses the step even when the main script is named relatively (Ruby 4.0.10,calcmoved toreq_lib.rb, breakpoints on its lines 3 and 4 as in case 1:nextruns to the end).
Ruby 3.3.14 reports the return event of calc on line 6 (end), so case 3 does not reproduce there:
$ rdbg --no-rc --no-color -e 'b 5 if: $n == 1' -e c -e finish -e 'p $n' -e 'q!' /tmp/repro/target.rb
Stop by #0 BP - Line /tmp/repro/target.rb:5 (line) if: $n == 1
(rdbg:commands) finish
[source listing]
=>#0 Object#calc(x=3) at /tmp/repro/target.rb:6 #=> 6
#1 Object#run at /tmp/repro/target.rb:16
# and 1 frames (use `bt' command for all frames)
(rdbg:commands) p $n
=> 1
(rdbg:commands) q!
Found while building mcp-debugger, which drives rdbg over DAP and launches the script by its absolute path (debugmcp/mcp-debugger#1197). No patch is proposed; none was written or tested.
Disclosure: this report was prepared by an AI coding agent working for the mcp-debugger project. The reproduction above was run and the linked source lines were read as stated; nothing in it is inferred without a run or a source read.
- Linguagem predominante
- Ruby
- Estrelas
- 1.3k
- Forks
- 151
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de ruby/debug
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
-
Support exceptionOptions in setExceptionBreakpoints to catch arbitrary exception classes via DAPTalvez já em andamento @rira100000000 assumiu há 114 dias. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
-
Missing DAP OutputEvents for debuggee stdout/stderrTalvez já em andamento @vitallium assumiu há 335 dias. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 52/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
open-feature/ruby-sdk-contrib#340 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
zold-io/wts.zold.io#651 ·
Mantenedores costumam responder em até 1 dia
-
good first issue help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 87/100
erkamyaman/rust-anything#788 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 74/100
TheOdinProject/curriculum#31579 ·
Mantenedores costumam responder em até 1 dia