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

decoding dwarf section - dlv problem to start app #3547

Closed
tzookb opened this issue Sep 24, 2024 · 20 comments
Closed

decoding dwarf section - dlv problem to start app #3547

tzookb opened this issue Sep 24, 2024 · 20 comments
Labels
Debug Issues related to the debugging functionality of the extension.
Milestone

Comments

@tzookb
Copy link

tzookb commented Sep 24, 2024

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.21.0 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.16.2
    golang.org/x/tools/[email protected] h1:K1z03MlikHfaMTtG01cUeL5FAOTJnITuNe0TWOcg8tM=
    github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/[email protected] h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
    golang.org/x/[email protected] h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
    golang.org/x/[email protected] h1:Wm3cG5X6sZ0RSVRc/H1/sciC4AT6HAKgLCSH2lbpR/c=
    golang.org/x/[email protected] h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
    golang.org/x/[email protected] h1:6bJEg2w2kUHWlfdJaESYsmNfI1LKAZQi6zCa7LUn7eI=
    golang.org/x/[email protected] h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
    honnef.co/go/[email protected] h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=
    mvdan.cc/[email protected] h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.21.0
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
1.93.1
38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
arm64
  • Check your installed extensions to get the version of the VS Code Go extension
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
# Tools Configuration


## Environment

GOBIN: /xxxx/build-support/go/bin
toolsGopath: 
gopath: /xxxx/build-support/go
GOROOT: /xxxx/build-support/go/go1.21.0/
PATH: /xxxxx/build-support/go/go1.21.0/bin:/Users/tzookb/.pyenv/shims:/usr/local/Cellar/postgresql@13/13.12/bin/:/Users/tzookb/.jenv/shims:/xxxx/build-support/go/bin:/Users/tzookb/.compass/bin:/xxxxx/build-support/go/sdk/bin:/Users/tzookb/.nvm/versions/node/v20.16.0/bin:/Applications/Banyan.app/Contents/Resources/bin/:/Users/tzookb/.my-exec:/usr/local/sbin:/usr/local/opt/[email protected]/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/tzookb/.cargo/bin:/Users/tzookb/Library/Python/3.9/bin:/Users/tzookb/.pyenv/shims:/usr/local/Cellar/postgresql@13/13.12/bin/:/Users/tzookb/.jenv/shims:/xxxxx/build-support/go/bin:/Users/tzookb/.compass/bin:/xxxxxx/build-support/go/sdk/bin:/Users/tzookb/.nvm/versions/node/v20.16.0/bin:/Applications/Banyan.app/Contents/Resources/bin/:/Users/tzookb/.my-exec:/usr/local/sbin:/usr/local/opt/[email protected]/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/tzookb/.cargo/bin
PATH (vscode launched with): /Users/tzookb/.pyenv/shims:/usr/local/Cellar/postgresql@13/13.12/bin/:/Users/tzookb/.jenv/shims:/xxxx/build-support/go/bin:/Users/tzookb/.compass/bin:/xxxxx/build-support/go/sdk/bin:/Users/tzookb/.nvm/versions/node/v20.16.0/bin:/Applications/Banyan.app/Contents/Resources/bin/:/Users/tzookb/.my-exec:/usr/local/sbin:/usr/local/opt/[email protected]/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/tzookb/.cargo/bin:/Users/tzookb/Library/Python/3.9/bin:/Users/tzookb/.pyenv/shims:/usr/local/Cellar/postgresql@13/13.12/bin/:/Users/tzookb/.jenv/shims:/xxxxxxxx/build-support/go/bin:/Users/tzookb/.compass/bin:/xxxxx/build-support/go/sdk/bin:/Users/tzookb/.nvm/versions/node/v20.16.0/bin:/Applications/Banyan.app/Contents/Resources/bin/:/Users/tzookb/.my-exec:/usr/local/sbin:/usr/local/opt/[email protected]/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/tzookb/.cargo/bin

## Tools

	go:	xxxxxx/build-support/go/go1.21.0/bin/go: go version go1.21.0 darwin/arm64

	gopls:	xxxxx/build-support/go/bin/gopls	(version: v0.16.2 built with go: go1.21.0)
	gotests:	not installed
	gomodifytags:	not installed
	impl:	not installed
	goplay:	not installed
	dlv:	/xxxxxxx/build-support/go/bin/dlv	(version: v1.23.1 built with go: go1.21.0)
	staticcheck:	not installed

## Go env

Workspace Folder (connected_accounts): /xxxxxxx/src/go/compass.com/connected_accounts

	GO111MODULE='on'
	GOARCH='arm64'
	GOBIN='/xxxxxx/build-support/go/bin'
	GOCACHE='/Users/tzookb/Library/Caches/go-build'
	GOENV='/Users/tzookb/Library/Application Support/go/env'
	GOEXE=''
	GOEXPERIMENT=''
	GOFLAGS='-modcacherw'
	GOHOSTARCH='arm64'
	GOHOSTOS='darwin'
	GOINSECURE=''
	GOMODCACHE='/xxxxx/build-support/go/pkg/mod'
	GONOPROXY=''
	GONOSUMDB='*'
	GOOS='darwin'
	GOPATH='/xxxxx/build-support/go'
	GOPRIVATE=''
	GOPROXY='https://[email protected]/repository/go'
	GOROOT='/xxxxxx/build-support/go/go1.21.0/'
	GOSUMDB='off'
	GOTMPDIR=''
	GOTOOLCHAIN='auto'
	GOTOOLDIR='/xxxxx/build-support/go/go1.21.0/pkg/tool/darwin_arm64'
	GOVCS=''
	GOVERSION='go1.21.0'
	GCCGO='gccgo'
	AR='ar'
	CC='clang'
	CXX='clang++'
	CGO_ENABLED='1'
	GOMOD='/xxxxx/src/go/compass.com/go.mod'
	GOWORK='/xxxx/go.work'
	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 -ffile-prefix-map=/var/folders/4c/tz1ybdq90bngpx087gtbgy7r0000gq/T/go-build1172643733=/tmp/go-build -gno-record-gcc-switches -fno-common'
	

Share the Go related settings you have added/edited

launch.json:

{
    "version": "0.2.0",
    "configurations": [
      {
        "name": "staging",
        "type": "go",
        "mode": "auto",
        "request": "launch",
        "program": "/xxxxxxx/connected_accounts/cmd/connected_accountsd/main.go",
        "debugAdapter": "dlv-dap",
        "args": [
            "--log-level=debug",
            "--env=staging",
            "--opty-service=grpc://opty.grpc.dev.na.xxxxx.com:31337",
            "--pg-connected-accounts-api-port=25434",
            "--people-service=grpc://peopleserver.grpc.dev.na.xxxxx.com:31337",
            "--aws-profile=crm"
        ],
        "trace": "verbose",
      }
    ]
  }

Describe the bug

running the app like always, but now I get: (attached screenshot)

Failed to launch: could not launch process: could not read debug info (decoding dwarf section info at offset 0x0: too short) and could not read go symbol table (could not find rodata struct member

Screenshots or recordings

Screenshot 2024-09-24 at 10 09 59
@gopherbot gopherbot added this to the Untriaged milestone Sep 24, 2024
@dunglas
Copy link

dunglas commented Sep 24, 2024

Same issue on my side, but only on projects using cgo. This works as expected on non-cgo projects.

@tzookb
Copy link
Author

tzookb commented Sep 24, 2024

I would say that I made it "work" by downgrading dlv to 1.21.2

rm -f $(which dlv)

./build-support/go/go1.21.0/bin/go install github.com/go-delve/delve/cmd/[email protected]

but now breakpoint are not stopping, as it says:

could not find file /xxxxx/src/go/example.com/contacts_interactions/server/contacts_interactions.go

@hyangah
Copy link
Contributor

hyangah commented Sep 24, 2024

Can you try to run dlv command directly and see if it works?
I think something like

cd /xxxxxxx/connected_accounts/cmd/connected_accountsd
dlv debug ./main.go

cc @derekparker @aarzilli

@tzookb
Copy link
Author

tzookb commented Sep 24, 2024

not sure if it worked or not :|

#:/ dlv debug ./main.go
Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.
Type 'help' for list of commands.

(dlv)
Screenshot 2024-09-24 at 18 23 45

@derekparker
Copy link
Contributor

@tzookb was this using the latest version of Delve? This error message is unusual especially considering Delve is building the binary. The binary seems to be created without any debug information.

A few questions:

  • Are you using CGO? Are you disabling DWARF (debug info) generation in any C compilation unit?
  • Do you have anything nonstandard during your build process that could be stripping the debug information during a build?

@tzookb
Copy link
Author

tzookb commented Sep 24, 2024

I just installed latest vscode-go, that installed latest dlv, as I don't want to jump hoops around versioning.

I tried to see what I can do here:
https://github.com/golang/vscode-go/blob/master/docs/debugging.md#starting-a-debug-session-fails-with

but I get the original error of the issue:

Failed to launch: could not launch process: could not read debug info (decoding dwarf section info at offset 0x0: too short) and could not read go symbol table (could not find rodata struct member

dlv (latest 1.23.1) debug errors now:

➜  connected_accountsd git:(master) ✗ dlv debug ./main.go

Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.
could not launch process: could not read debug info (decoding dwarf section info at offset 0x0: too short) and could not read go symbol table (could not find rodata struct member)

we are using a this go version: go version go1.21.0 darwin/arm64

  • Are you using CGO? Are you disabling DWARF (debug info) generation in any C compilation unit?
    • I don't think so, Ill verify
  • Do you have anything nonstandard during your build process that could be stripping the debug information during a build?
    • Im passing the program file full path, so I assume the extension builds and runs the file by itself, I didn't pass any special flags

@aarzilli
Copy link
Contributor

Could be a duplicate of go-delve/delve#3701, knowing whether you are using CGO would be important.

What's the output of clang --version, ld -v and dsymutil -v?

@tzookb
Copy link
Author

tzookb commented Sep 25, 2024

clang --version

Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

ld -v

@(#)PROGRAM:ld PROJECT:ld-1115.7.3
BUILD 13:29:00 Aug  9 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 16.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 16.0.0 (tapi-1600.0.11.8)

dsymutil -v

Apple LLVM version 16.0.0
   (clang-1600.0.26.3)Optimized build.

xcode version: /usr/bin/xcodebuild -version

Xcode 16.0
Build version 16A242d

I couldn't replicate the other pr solution :|

@aarzilli
Copy link
Contributor

What about cgo? Does it use it? Also can you post the binary executable built with go build -gcflags='all=-N -l' ... somewhere?

@dunglas
Copy link

dunglas commented Sep 25, 2024

In my case, cgo is heavily used (and I haven't the problem on non-cgo projects) and I've the same problem when using the command line:

CGO_CFLAGS="$(/usr/local/bin/php-config --includes) -I/opt/homebrew/include/" CGO_LDFLAGS="$(/usr/local/bin/
php-config --ldflags) $(/usr/local/bin/php-config --libs) -L/opt/homebrew/lib/" dlv debug main.go 
WARN[0000] CGO_CFLAGS already set, Cgo code could be optimized.  layer=dlv
# command-line-arguments
ld: warning: ignoring duplicate libraries: '-lcrypto', '-liconv', '-lpthread', '-lresolv', '-lsqlite3', '-lssl', '-lxml2'
Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.
could not launch process: could not read debug info (decoding dwarf section info at offset 0x0: too short) and could not read go symbol table (could not find rodata struct member)
go version
go version go1.22.0 darwin/arm64
clang --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
ld -v
@(#)PROGRAM:ld PROJECT:ld-1115.7.3
BUILD 13:29:00 Aug  9 2024
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
will use ld-classic for: armv6 armv7 armv7s i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 16.0.0 (static support for 29, runtime is 29)
TAPI support using: Apple TAPI version 16.0.0 (tapi-1600.0.11.8)
dsymutil -v
Apple LLVM version 16.0.0
   (clang-1600.0.26.3)Optimized build.
/usr/bin/xcodebuild -version
Xcode 16.0
Build version 16A242d

@dunglas
Copy link

dunglas commented Sep 25, 2024

This looks to be the same issue as: go-delve/delve#1138 (comment)
However, I tried to upgrade delve and the other workaround and nothing fixes the issue in my case.

@aarzilli
Copy link
Contributor

cc @cherrymui it could be that the problem that existed with custom clang toolchains now also affects the xcode toolchain.

@dunglas
Copy link

dunglas commented Sep 25, 2024

I also notified a weird issue that may, or may not be related.

Starting the program with go run main.go works, but building it with go build and then executing it fails with this error:

terminated by signal SIGKILL (Forced quit)

However, executing the binary that is killed through LLDB (lldb ./mybinary) surprisingly works.

@dunglas
Copy link

dunglas commented Sep 25, 2024

I figured out the issue on my side: it is because the project has toolchain go1.22.0 in its go.mod.
Setting the environment variable GOTOOLCHAIN to auto to force using the system installation fixes both Delve and go build. Thanks for your time and sorry for the noise.

Edit: the root of the issue was that ~/Library/Application\ Support/go/env was containing a GOTOOLCHAIN variable (I've no idea why, I probably messed it up at some point). Removing this file definitely fixed the issue.

@tzookb
Copy link
Author

tzookb commented Sep 25, 2024

at least for me I noticed that for an app that include packages that needs "CGO_ENABLED" it fails with the mentioned error.

it depends on
https://github.com/confluentinc/confluent-kafka-go

@aarzilli
Copy link
Contributor

@tzookb can you upgrade to go1.23 and see if the problem still reproduces?

@tzookb
Copy link
Author

tzookb commented Sep 26, 2024

checked with 1.23
and Im able to run and debug 😮‍💨

@aarzilli
Copy link
Contributor

I think this can be closed.

@tzookb
Copy link
Author

tzookb commented Sep 26, 2024

do we have a suggestion for go 1.21?

@findleyr
Copy link
Contributor

Thanks @aarzilli @dunglas and @derekparker for your help investigating.

do we have a suggestion for go 1.21?

@tzookb as Go 1.21 is not supported by the Go release policy, I don't think we'll be able to help. If you must use 1.21, your solution above (downgrading delve) may be necessary.

@hyangah hyangah added the Debug Issues related to the debugging functionality of the extension. label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Debug Issues related to the debugging functionality of the extension.
Projects
None yet
Development

No branches or pull requests

7 participants