Skip to content
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') #2949

Closed
yairy opened this issue Aug 22, 2023 · 5 comments
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge

Comments

@yairy
Copy link

yairy commented Aug 22, 2023

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.20.2 darwin/arm64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • Build info

golang.org/x/tools/gopls v0.13.2
golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=
github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp/typeparams@v0.0.0-20221212164502-fae10dda9338 h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
golang.org/x/mod@v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/sync@v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sys@v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/text@v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/tools@v0.11.2-0.20230810185051-cc6b5804b8cf h1:Oush7UwPamr2/iNeNFBuNFj89YyHn0YY69EKDdvANnk=
golang.org/x/vuln@v0.0.0-20230110180137-6ad3e3d07815 h1:A9kONVi4+AnuOr1dopsibH6hLi1Huy54cbeJxnq4vmU=
honnef.co/go/tools@v0.4.2 h1:6qXr+R5w+ktL5UkwEbPp+fEvfyoMPche6GkOpGHZcLc=
mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.20.2

  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • 1.81.1
      6c3e3dba23e8fadc360aed75ce363ba185c49794
      arm64
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.39.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

    • Checking configured tools....
      GOBIN: undefined
      toolsGopath:
      gopath: /Users/yairyehuda/go
      GOROOT: /opt/homebrew/opt/go@1.20/libexec
      PATH: /opt/homebrew/opt/go@1.20/libexec/bin:/Users/yairyehuda/.nvm/versions/node/v16.19.1/bin:/Users/yairyehuda/Library/Caches/fnm_multishells/1625_1692648289542/bin:/Users/yairyehuda/.krew/bin:/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/Users/yairyehuda/Library/Python/3.8/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/tools:/platform-tools:/Users/yairyehuda/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/yairyehuda/.fig/bin:/Users/yairyehuda/.local/bin:/Users/yairyehuda/go/bin:/platform-tools:/Users/yairyehuda/.fig/bin:/tools
      PATH (vscode launched with): /Users/yairyehuda/.nvm/versions/node/v16.19.1/bin:/Users/yairyehuda/Library/Caches/fnm_multishells/1625_1692648289542/bin:/Users/yairyehuda/.krew/bin:/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/Users/yairyehuda/Library/Python/3.8/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/tools:/platform-tools:/Users/yairyehuda/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/yairyehuda/.fig/bin:/Users/yairyehuda/.local/bin:/Users/yairyehuda/go/bin:/opt/homebrew/opt/go@1.20/libexec/bin:/platform-tools:/Users/yairyehuda/.fig/bin:/opt/homebrew/opt/go@1.20/libexec/bin:/tools

    go: /opt/homebrew/opt/go@1.20/libexec/bin/go: go version go1.20.2 darwin/arm64

    gotests: /Users/yairyehuda/go/bin/gotests (version: v1.6.0 built with go: go1.20.2)
    gomodifytags: /Users/yairyehuda/go/bin/gomodifytags (version: v1.16.0 built with go: go1.20.2)
    impl: /Users/yairyehuda/go/bin/impl (version: v1.1.0 built with go: go1.20.2)
    goplay: /Users/yairyehuda/go/bin/goplay (version: v1.0.0 built with go: go1.20.2)
    dlv: /Users/yairyehuda/go/bin/dlv (version: v1.20.1 built with go: go1.20.2)
    staticcheck: /Users/yairyehuda/go/bin/staticcheck (version: v0.4.3 built with go: go1.20.2)
    gopls: /Users/yairyehuda/go/bin/gopls (version: v0.13.2 built with go: go1.20.2)

go env
Workspace Folder (multistage): /Users/yairyehuda/git/DemoApps/go/multistage
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/yairyehuda/Library/Caches/go-build"
GOENV="/Users/yairyehuda/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/yairyehuda/go/pkg/mod"
GONOPROXY="github.com/techvelocity/"
GONOSUMDB="github.com/techvelocity/
"
GOOS="darwin"
GOPATH="/Users/yairyehuda/go"
GOPRIVATE="github.com/techvelocity/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/opt/go@1.20/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/opt/go@1.20/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/yairyehuda/git/DemoApps/go/multistage/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8j/3yxy6kp52rq6hbdjtc5qr5fw0000gn/T/go-build741162924=/tmp/go-build -gno-record-gcc-switches -fno-common"

Describe the bug

I'm getting the following exception when trying to debug a remote process:

Unhandled error in debug adapter: TypeError: Cannot read properties of undefined (reading 'addr')
    at GoDebugSession.convertDebugVariableToProtocolVariable (/Users/myname/.vscode/extensions/golang.go-0.39.1/dist/debugAdapter.js:17384:51)
    at /Users/myname/.vscode/extensions/golang.go-0.39.1/dist/debugAdapter.js:16864:59
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 1)

My debug configuration in launch.json is:

        {
            "name": "My Debug Session",
            "type": "go",
            "request": "attach",
            "mode": "remote",
            "remotePath": "",
            "cwd": "${workspaceFolder}",
            "port": 2345,
            "stopOnEntry": false,
            "host": "127.0.0.1",
            "showLog": true,
            "trace": "log"
        }

I see that a very similar issue was fixed here:
https://github.com/golang/vscode-go/pull/2618/files

However, the same problem exists here:
https://github.com/golang/vscode-go/blob/master/src/debugAdapter/goDebug.ts#L2343

if v.children is an empty array then v.children[0].addr will crash.

Reproduce steps:

For me, it happens when I start a remote debug session. After it connects successfully, I press the 'pause' button in the debug toolbar.

@gopherbot gopherbot added this to the Untriaged milestone Aug 22, 2023
@findleyr
Copy link
Member

CC @hyangah @suzmue

@findleyr findleyr added the Debug Issues related to the debugging functionality of the extension. label Aug 22, 2023
@hyangah
Copy link
Contributor

hyangah commented Aug 22, 2023

Have you tried the delve DAP?

https://github.com/golang/vscode-go/wiki/debugging#remote-debugging
I think adding "debugAdapter": "dlv-dap" in the setting will select the delve DAP instead of the legacy debug adapter.

@yairy
Copy link
Author

yairy commented Aug 24, 2023

It doesn't crash anymore using dlv-dap, thank you!
I don't know if the legacy Debug Adapter is still maintained, but IMO it's worth fixing.

@findleyr
Copy link
Member

Hi @yairy, unfortunately we don't have resources to address bugs with the legacy debug adapter; it will eventually be removed. Glad to hear the delve DAP adapter is working.

@hyangah assuming you agree, shall we close this?

@hyangah
Copy link
Contributor

hyangah commented Aug 30, 2023

Thanks for letting us know dlv-dap works for you, @yairy

We are going to change the default debug adapter for remote debugging to the new dlv-dap. #2205

@findleyr Yes, let's close this.

@hyangah hyangah closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2023
@golang golang locked and limited conversation to collaborators Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

4 participants