-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled error in debug adapter: TypeError: Cannot read properties of undefined (reading 'addr') #2397
Comments
CC @suzmue |
Weirdly it works if Variable panel is closed while in debug mode. |
When I move the mouse to variable name in code, it failed again. |
Happened with me to... go version: gopls version The Variable panel trick is getting me going... |
Strangely, this do not occur during my normal debug sessions, only when I'm doing something on early stages of app startup. |
I have encountered same issue and solved it by setting substitutePath in Not sure if this applies every situation, but hope it might help someone! may launch.json is like below
|
Maybe this helps: I hit this now while trying to debug a locally-built podman where I had all standard build flags enabled (i.e. no dlv exec ${workspaceFolder}/bin/podman --api-version 2 --headless --listen 127.0.0.1:2345 --accept-multiclient -- version (modified the VSCode launch config used to connect: {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Connect to server",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 2345,
"host": "127.0.0.1"
}
]
} Breakpoint to hit is at version.go. I didn't want to spend too much time now to figure this out, and I definitely need the variables panel, so I went ahead and modified my debugAdapter.js in ~/.vscode-insiders/extensions/golang.go-0.36.0/dist to basically ignore an undefined: --- debugAdapter.js.orig 2022-12-12 18:50:04.836913630 +0100
+++ debugAdapter.js 2022-12-12 18:40:57.545961396 +0100
@@ -16725,7 +16725,12 @@
variablesReference: 0
};
} else if (v.kind === 22) {
- if (v.children[0].addr === 0) {
+ if (!v.children[0]) {
+ return {
+ result: "gone <" + v.type + ">",
+ variablesReference: 0
+ };
+ } else if (v.children[0].addr === 0) {
return {
result: "nil <" + v.type + ">",
variablesReference: 0 Works for me, and in the variables window I see one "gone" variable: |
@ankon thank you! This worked for me. |
@ankon this worked for me as well! Thanks! |
It seems that we might hit variables here that "exist" but do not have information for them at all. Handle that case by reporting them as "gone". Fixes golang#2397
I guess it's worth trying a PR then: See #2618 for what I hope should be fine. :) |
Change https://go.dev/cl/462289 mentions this issue: |
Has this fix been released yet? |
It's seems not yet. |
Great solution 👍 Almost 5 months later and after try and error, I finally found the root cause of this exception. When we build the application, the go complier will the final solution is to turn off build optimization and build the application again, for example:
after restart the application, there is no Exception again, all were went well. Hope this message can help you all guys. |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.golang.org/x/tools/gopls v0.9.1
golang.org/x/tools/[email protected] h1:SigsTL4Hpv3a6b/a7oPCLRv5QUeSM6PZNdta1oKY4B0=
github.com/BurntSushi/[email protected] h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
github.com/google/[email protected] h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/exp/[email protected] h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=
golang.org/x/[email protected] h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/[email protected] h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/[email protected] h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
golang.org/x/[email protected] h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/[email protected] h1:Ljlba2fVWOA1049JjsKii44g8nZN2GjpxMlzVc8AnQM=
golang.org/x/[email protected] h1:r5bbIROBQtRRgoutV8Q3sFY58VzHW6jMBYl48ANSyS4=
honnef.co/go/[email protected] h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=
mvdan.cc/[email protected] h1:kTojdZo9AcEYbQYhGuLf/zszYthRdhDNDUi2JKTxas4=
mvdan.cc/xurls/[email protected] h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.19
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.da76f93349a72022ca4670c1b84860304616aaa2
arm64
Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Share all the settings with the
go.
or["go"]
orgopls
prefixes.Describe the bug
below is my launch.json configuration:
I'v added some breakpoints on several lines, after launch.json configuration was set, I connected to the remote dlv debugger server, and it's log shows all fine.
When I triggered the API request on remote host, the debug session created an VS Code show Local and Global varibles, but shortly, the debug session ended an the debug log show the following error message:
I'v Googled around and found some information about
legacy
anddlv-dap
mode, but I am not sure what exactly it is. So I modified the launch.json configuration by adddebugAdapter
, as follow:after try again, the debug session created but VS Code automatically open the response file I added breakpoints but in another path, like
/tmp.go-buildxxxxxxxxx/src/xxx......
, the VS Code UI as follow:I'v degraded Go extension to lower version as well, but the same result.
the remote dlv debugger server run command is:
The text was updated successfully, but these errors were encountered: