Skip to content

Look up the root frame before running a stepping command - #427

Open
KristofferC wants to merge 1 commit into
masterfrom
kc/root-before-command
Open

KristofferC wants to merge 1 commit into
masterfrom
kc/root-before-command

Conversation

@KristofferC

@KristofferC KristofferC commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

When a stepping command finishes the debugged call, execute_command read the result with get_return(root(state.frame)). By then JuliaInterpreter has put the finished frames back in its reuse pool (junk_frames), and the object in state.frame may already have been reused.

Frames reused inside the debugged call still walk up to the right root, so ordinary code is not affected. It breaks when, during the command, a frame is created outside the debugged call tree, e.g. when the debugged code itself uses JuliaInterpreter (@interpret, or a package such as Revise that uses it internally). The recycled leaf then becomes the root of that other call, and @run returns its result:

@noinline f(x) = x * 10
function g(x)
    a = f(x)
    b = JuliaInterpreter.@interpret identity(42)
    return a + b
end
breakpoint(f); @run g(1)   # c  →  returned 42, should be 52

The root is now looked up before calling debug_command. This also makes Debugger independent of when JuliaInterpreter reuses frames.

The added test fails without the fix (42 == 52).

🤖 Generated with Claude Code

When a stepping command finishes the debugged call, `execute_command` read the
result with `get_return(root(state.frame))`. By then JuliaInterpreter has
recycled the finished frames, and the object in `state.frame` can already have
been reused for a frame of another call tree, so the root found through it is
not the root of the debugged call. For example, when the debugged code itself
runs `JuliaInterpreter.@interpret`, `@run` returned the result of that inner
call (`42` instead of `52` in the added test).

The root is now looked up before calling `debug_command`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant