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

Cannot debug glfw: error reading debug_info: decoding dwarf section line_str at offset 0x0: underflow #1914

Closed
dah33 opened this issue Nov 27, 2021 · 7 comments
Labels
Debug Issues related to the debugging functionality of the extension. FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@dah33
Copy link

dah33 commented Nov 27, 2021

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.17.3 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.7.3
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.62.3
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.29.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
GOBIN: undefined
toolsGopath: 
gopath: C:\Users\danho\go
GOROOT: C:\Program Files\Go
PATH: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program Files\Amazon\AWSCLIV2\;C:\Users\danho\anaconda3;C:\Users\danho\anaconda3\Scripts;C:\Users\danho\anaconda3\Library\bin;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Azure Data Studio\bin;C:\Program Files\Git\cmd;C:\Program Files\Go\bin;C:\Users\danho\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts;C:\Users\danho\AppData\Local\GitHubDesktop\bin;C:\Program Files\JetBrains\PyCharm Community Edition 2020.2.3\bin;;%DataGrip%;C:\Program Files\PostgreSQL\12\bin;C:\Program Files\Sublime Text 3;C:\Program Files\Azure Data Studio\bin;C:\Users\danho\go\bin;C:\msys64\mingw64\bin;;C:\Users\danho\AppData\Local\Programs\Microsoft VS Code\bin

	go:	C:\Program Files\Go\bin\go.exe: go version go1.17.3 windows/amd64

	gopkgs:	C:\Users\danho\go\bin\gopkgs.exe: go1.17.3
		path	github.com/uudashr/gopkgs/v2/cmd/gopkgs
		mod	github.com/uudashr/gopkgs/v2	v2.1.2	h1:A0+QH6wqNRHORJnxmqfeuBEsK4nYQ7pgcOHhqpqcrpo=
		dep	github.com/karrick/godirwalk	v1.12.0	h1:nkS4xxsjiZMvVlazd0mFyiwD4BR9f3m6LXGhM2TUx3Y=
		dep	github.com/pkg/errors	v0.8.1	h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
	
	go-outline:	C:\Users\danho\go\bin\go-outline.exe: go1.17.3
		path	github.com/ramya-rao-a/go-outline
		mod	github.com/ramya-rao-a/go-outline	v0.0.0-20210608161538-9736a4bde949	h1:iaD+iVf9xGfajsJp+zYrg9Lrk6gMJ6/hZHO4cYq5D5o=
		dep	golang.org/x/tools	v0.1.1	h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs=
	
	gotests:	not installed
	gomodifytags:	not installed
	impl:	not installed
	goplay:	not installed
	dlv:	C:\Users\danho\go\bin\dlv.exe: go1.17.3
		path	github.com/go-delve/delve/cmd/dlv
		mod	github.com/go-delve/delve	v1.7.3	h1:5I8KjqwKIz6I7JQ4QA+eY5PRB0+INs9h7wEDRzFnuHQ=
		dep	github.com/cilium/ebpf	v0.7.0	h1:1k/q3ATgxSXRdrmPfH8d7YK0GfqVsEKZAX9dQZvs56k=
		dep	github.com/cosiner/argv	v0.1.0	h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg=
		dep	github.com/cpuguy83/go-md2man/v2	v2.0.0	h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
		dep	github.com/derekparker/trie	v0.0.0-20200317170641-1fdf38b7b0e9	h1:G765iDCq7bP5opdrPkXk+4V3yfkgV9iGFuheWZ/X/zY=
		dep	github.com/google/go-dap	v0.6.0	h1:Y1RHGUtv3R8y6sXq2dtGRMYrFB2hSqyFVws7jucrzX4=
		dep	github.com/hashicorp/golang-lru	v0.5.4	h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
		dep	github.com/inconshreveable/mousetrap	v1.0.0	h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
		dep	github.com/konsorten/go-windows-terminal-sequences	v1.0.3	h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
		dep	github.com/mattn/go-colorable	v0.0.9	h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
		dep	github.com/mattn/go-isatty	v0.0.3	h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
		dep	github.com/mattn/go-runewidth	v0.0.3	h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
		dep	github.com/peterh/liner	v1.2.1	h1:O4BlKaq/LWu6VRWmol4ByWfzx6MfXc5Op5HETyIy5yg=
		dep	github.com/russross/blackfriday/v2	v2.0.1	h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
		dep	github.com/shurcooL/sanitized_anchor_name	v1.0.0	h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
		dep	github.com/sirupsen/logrus	v1.6.0	h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
		dep	github.com/spf13/cobra	v1.1.3	h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
		dep	github.com/spf13/pflag	v1.0.5	h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
		dep	go.starlark.net	v0.0.0-20200821142938-949cc6f4b097	h1:YiRMXXgG+Pg26t1fjq+iAjaauKWMC9cmGFrtOEuwDDg=
		dep	golang.org/x/arch	v0.0.0-20190927153633-4e8777c89be4	h1:QlVATYS7JBoZMVaf+cNjb90WD/beKVHnIxFKT4QaHVI=
		dep	golang.org/x/sys	v0.0.0-20211019181941-9d821ace8654	h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
		dep	gopkg.in/yaml.v2	v2.4.0	h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
	
	dlv-dap:	C:\Users\danho\go\bin\dlv-dap.exe: go1.17.3
		path	github.com/go-delve/delve/cmd/dlv
		mod	github.com/go-delve/delve	v1.7.4-0.20211126161129-75bbbbb60cec	h1:ZJ3UQKzs6NcqKVoIyC/kIdO+0noy2DDA/Qg/r6TtSAo=
		dep	github.com/cilium/ebpf	v0.7.0	h1:1k/q3ATgxSXRdrmPfH8d7YK0GfqVsEKZAX9dQZvs56k=
		dep	github.com/cosiner/argv	v0.1.0	h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg=
		dep	github.com/cpuguy83/go-md2man/v2	v2.0.0	h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
		dep	github.com/derekparker/trie	v0.0.0-20200317170641-1fdf38b7b0e9	h1:G765iDCq7bP5opdrPkXk+4V3yfkgV9iGFuheWZ/X/zY=
		dep	github.com/google/go-dap	v0.6.0	h1:Y1RHGUtv3R8y6sXq2dtGRMYrFB2hSqyFVws7jucrzX4=
		dep	github.com/hashicorp/golang-lru	v0.5.4	h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
		dep	github.com/inconshreveable/mousetrap	v1.0.0	h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
		dep	github.com/konsorten/go-windows-terminal-sequences	v1.0.3	h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
		dep	github.com/mattn/go-colorable	v0.0.9	h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
		dep	github.com/mattn/go-isatty	v0.0.3	h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
		dep	github.com/mattn/go-runewidth	v0.0.3	h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
		dep	github.com/peterh/liner	v1.2.1	h1:O4BlKaq/LWu6VRWmol4ByWfzx6MfXc5Op5HETyIy5yg=
		dep	github.com/russross/blackfriday/v2	v2.0.1	h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
		dep	github.com/shurcooL/sanitized_anchor_name	v1.0.0	h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
		dep	github.com/sirupsen/logrus	v1.6.0	h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
		dep	github.com/spf13/cobra	v1.1.3	h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
		dep	github.com/spf13/pflag	v1.0.5	h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
		dep	go.starlark.net	v0.0.0-20200821142938-949cc6f4b097	h1:YiRMXXgG+Pg26t1fjq+iAjaauKWMC9cmGFrtOEuwDDg=
		dep	golang.org/x/arch	v0.0.0-20190927153633-4e8777c89be4	h1:QlVATYS7JBoZMVaf+cNjb90WD/beKVHnIxFKT4QaHVI=
		dep	golang.org/x/sys	v0.0.0-20211019181941-9d821ace8654	h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
		dep	gopkg.in/yaml.v2	v2.4.0	h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
	
	staticcheck:	C:\Users\danho\go\bin\staticcheck.exe: go1.17.3
		path	honnef.co/go/tools/cmd/staticcheck
		mod	honnef.co/go/tools	v0.2.2	h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1xvnzk=
		dep	github.com/BurntSushi/toml	v0.3.1	h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
		dep	golang.org/x/mod	v0.3.0	h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
		dep	golang.org/x/sys	v0.0.0-20210119212857-b64e53b001e4	h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k=
		dep	golang.org/x/tools	v0.1.0	h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
		dep	golang.org/x/xerrors	v0.0.0-20200804184101-5ec99f83aff1	h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
	
	gopls:	C:\Users\danho\go\bin\gopls.exe: go1.17.3
		path	golang.org/x/tools/gopls
		mod	golang.org/x/tools/gopls	v0.7.3	h1:Lru57ht8vtDMouRskFC085VAjBAZRAISd/lwvwOOV0Q=
		dep	github.com/BurntSushi/toml	v0.3.1	h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
		dep	github.com/google/go-cmp	v0.5.6	h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
		dep	github.com/sergi/go-diff	v1.1.0	h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
		dep	golang.org/x/mod	v0.4.2	h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
		dep	golang.org/x/sync	v0.0.0-20210220032951-036812b2e83c	h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
		dep	golang.org/x/sys	v0.0.0-20210809222454-d867a43fc93e	h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
		dep	golang.org/x/text	v0.3.6	h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
		dep	golang.org/x/tools	v0.1.8-0.20211014194737-fc98fb2abd48	h1:hk7xRoeg0CG1nRLsd5BZLDUgVpA9bnKylGk1p2/BPH0=
		dep	golang.org/x/xerrors	v0.0.0-20200804184101-5ec99f83aff1	h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
		dep	honnef.co/go/tools	v0.2.0	h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
		dep	mvdan.cc/gofumpt	v0.1.1	h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
		dep	mvdan.cc/xurls/v2	v2.3.0	h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=
	

go env
Workspace Folder (brianwill-nes): c:\Users\danho\OneDrive\Documents\Projects\nes\brianwill-nes
	set GO111MODULE=
	set GOARCH=amd64
	set GOBIN=
	set GOCACHE=C:\Users\danho\AppData\Local\go-build
	set GOENV=C:\Users\danho\AppData\Roaming\go\env
	set GOEXE=.exe
	set GOEXPERIMENT=
	set GOFLAGS=
	set GOHOSTARCH=amd64
	set GOHOSTOS=windows
	set GOINSECURE=
	set GOMODCACHE=C:\Users\danho\go\pkg\mod
	set GONOPROXY=
	set GONOSUMDB=
	set GOOS=windows
	set GOPATH=C:\Users\danho\go
	set GOPRIVATE=
	set GOPROXY=https://proxy.golang.org,direct
	set GOROOT=C:\Program Files\Go
	set GOSUMDB=sum.golang.org
	set GOTMPDIR=
	set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
	set GOVCS=
	set GOVERSION=go1.17.3
	set GCCGO=gccgo
	set AR=ar
	set CC=gcc
	set CXX=g++
	set CGO_ENABLED=1
	set GOMOD=c:\Users\danho\OneDrive\Documents\Projects\nes\brianwill-nes\go.mod
	set CGO_CFLAGS=-g -O2
	set CGO_CPPFLAGS=
	set CGO_CXXFLAGS=-g -O2
	set CGO_FFLAGS=-g -O2
	set CGO_LDFLAGS=-g -O2
	set PKG_CONFIG=pkg-config
	set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\danho\AppData\Local\Temp\go-build1153342000=/tmp/go-build -gno-record-gcc-switches

Share the Go related settings you have added/edited

None.

Describe the bug

Running the debugger I get a modal dialog: "Failed to launch: could not launch process: error reading debug_info: decoding dwarf section line_str at offset 0x0: underflow"

main.go

package main

import (
	"github.com/go-gl/glfw/v3.3/glfw"
)

func main() {
	glfw.Init()
}

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceFolder}"
        }
    ]
}

go.mod

module foo

go 1.17

require (
	github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211024062804-40e447a793be
)

go.sum

github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211024062804-40e447a793be h1:Z28GdQBfKOL8tNHjvaDn3wHDO7AzTRkmAXvHvnopp98=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20211024062804-40e447a793be/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@gopherbot gopherbot added this to the Untriaged milestone Nov 27, 2021
@hyangah
Copy link
Contributor

hyangah commented Nov 29, 2021

@dah33 Thanks for the report. Can you please try debugging with dlv to see if the problem is reproducible with dlv?

$ dlv debug
(dlv) b main.main
...

@hyangah hyangah added Debug Issues related to the debugging functionality of the extension. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Nov 29, 2021
@dah33
Copy link
Author

dah33 commented Dec 1, 2021

Looks very broken:

(dlv) b main.main
Command failed: location "main.main" not found
(dlv) funcs
(dlv) sources
(dlv) 

If I remove the glfw.Init() code and replace with say fmt.Println("hello, world") then it works as expected:

(dlv) b main.main
Breakpoint 1 set at 0x312aa6 for main.main() c:/users/danho/onedrive/documents/projects/nes/test/foo.go:5
(dlv) sources
<autogenerated>
C:/Program Files/Go/src/errors/errors.go
C:/Program Files/Go/src/errors/wrap.go
C:/Program Files/Go/src/fmt/doc.go
C:/Program Files/Go/src/fmt/errors.go
(dlv) c
> main.main() c:/users/danho/onedrive/documents/projects/nes/test/foo.go:5 (hits goroutine(1):1 total:1) (PC: 0x312aa6)
     1: package main
     2:
     3: import "fmt"
     4:
=>   5: func main() {
     6:         fmt.Println("hello, world")
     7:         //glfw.Init()
     8: }
...

So it seems like my code is silently breaking the command line debugger?

@hyangah
Copy link
Contributor

hyangah commented Dec 1, 2021

Assuming you installed all the libraries required to correctly use glfw,
can you build the program with the following command and share the compiled binary here for inspection?

go build -gcflags='all=-N -l'

Since glfw involves cgo and non-Go code heavily, it can be an issue in go compiler or delve.

@dah33
Copy link
Author

dah33 commented Dec 2, 2021

@hyangah
Copy link
Contributor

hyangah commented Dec 5, 2021

@dah33 Thank you so much for sharing the binary. I see some compile units from c99/C11 with DWARF5.
I am guessing go-delve/delve#2786 and golang/go#49590 are relevant. I hope you have a better luck if you try go1.18 and the dlv built from the master. (cc @aarzilli @thanm)

btw I was curious so I tried to reproduce the issue from my windows box today, but failed to reproduce it using the example repro case. Skimming through the debug info, I see @dah33 and I used different mingw installation (mingw-w64-crt vs
mingw-w64) and my binary didn't include DWARF5 at all. 🤷🏽‍♀️

@annomel
Copy link

annomel commented Dec 5, 2021

@hyangah I think you are using older mingw (msys2). I could debug in msys2 before but after updating to msys2-x86_64-20210725 I got into the same situation as go-delve/delve#2786.

@hyangah
Copy link
Contributor

hyangah commented Dec 5, 2021

@annomel Of course, toolings in my mingw-w64 installation is older than mingw-w64-crt so it generates DWARF4 not DWARF5. The culprit is delve and the std library delve depended on didn't handle DWARF5. It's delve and go's issue, so I am closing it. Until then, use old toolings, or try delve built from the master branch with the Go built from tip.

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 WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants