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!