Skip to content

Julia VS Code debugger crash #3704

@l8l

Description

@l8l

OS: Linux, Debian
Julia version: Most recent stable release


I am trying to debug code in the julia vscode debugger. Usually all goes well but when setting a breakpoint inside a function, that is called by an imported library, the debugger crashes when trying to display the variables in the scope.

More specifically, in the vscode settings I set

"julia.debuggerDefaultCompiled": [
    "ALL_MODULES_EXCEPT_MAIN",
    "-Lux.",
    "-Lux.Training",
    "-Lux.Training.compute_gradients",
]

and I try to debug the code where I use a custom loss function in some machine learning Lux code, where the loss function is called by the Lux-function, that computes gradients. For reference, here is a snippet of the code:

loss_function = function(model,ps,state,data)
    (x,y) = data
    y_p, state = model(x,ps,state)
    stats = []
    return mean((y_p.-y).^2), state, stats
end


_, loss, _, tstate = Training.single_train_step!(vjp, loss_function, data, tstate)

The code runs fine without debugger mode. However, even though the debugger jumps to the breakpoint, which is set at the line where you see stats = [], it directly thereafter crashes, when trying to display the variables in scope, with the following error:

> Connecting to debugger… Done!

┌ Error: Some Julia code in the VS Code extension crashed
└ @ VSCodeDebugger ~/.vscode-server/extensions/julialang.language-julia-1.79.2/scripts/error_handler.jl:15
ERROR: AssertionError: !(is_generated(method))
Stacktrace:
[1] compute_corrected_linerange
@ ~/.vscode-server/extensions/julialang.language-julia-1.79.2/scripts/packages/JuliaInterpreter/src/utils.jl:441 [inlined]
[2] scopes_request(conn::VSCodeDebugger.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, state::VSCodeDebugger.DebugAdapter.DebuggerState, params::VSCodeDebugger.DebugAdapter.ScopesArguments)
@ VSCodeDebugger.DebugAdapter ~/.vscode-server/extensions/julialang.language-julia-1.79.2/scripts/packages/DebugAdapter/src/debugger_requests.jl:561
[3] (::VSCodeDebugger.DebugAdapter.var"#129#155"{VSCodeDebugger.DebugAdapter.DebuggerState})(conn::VSCodeDebugger.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::VSCodeDebugger.DebugAdapter.ScopesArguments)
@ VSCodeDebugger.DebugAdapter ~/.vscode-server/extensions/julialang.language-julia-1.79.2/scripts/packages/DebugAdapter/src/packagedef.jl:56
[4] dispatch_msg(x::VSCodeDebugger.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::VSCodeDebugger.JSONRPC.MsgDispatcher, msg::Dict{String, Any})
@ VSCodeDebugger.JSONRPC ~/.vscode-server/extensions/julialang.language-julia-1.79.2/scripts/packages/JSONRPC/src/typed.jl:67
[5] (::VSCodeDebugger.DebugAdapter.var"#146#172"{VSCodeDebugger.var"#3#4"{Tuple{String, String}}, VSCodeDebugger.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, VSCodeDebugger.JSONRPC.MsgDispatcher})()
@ VSCodeDebugger.DebugAdapter ~/.vscode-server/extensions/julialang.language-julia-1.79.2/scripts/packages/DebugAdapter/src/packagedef.jl:76

Does anybody know why and how to resolve this? Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions