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

DW_FORM_strx with no .debug_str_offsets section #3797

Closed
Jasstkn opened this issue Aug 20, 2024 · 30 comments · Fixed by #3799
Closed

DW_FORM_strx with no .debug_str_offsets section #3797

Jasstkn opened this issue Aug 20, 2024 · 30 comments · Fixed by #3799

Comments

@Jasstkn
Copy link

Jasstkn commented Aug 20, 2024

Minimal code to reproduce an issue: https://go.dev/play/p/mT1pjsWIx9x. The same issue happens when using this dependency:

helm.sh/helm/v3/pkg/cli/values

go build works normally with no errors.

  1. What version of Delve are you using (dlv version)?
Delve Debugger
Version: 1.23.0
Build: $Id: e673f2da02185a1c2b6dea52842b0a8c7e7a03b9 $
  1. What version of Go are you using? (go version)?
go version go1.23.0 darwin/arm64
  1. What operating system and processor architecture are you using?
    MacOS on ARM, issue started to be reproduced since MacOS 15 Beta(24A5327a).
  2. What did you do?
    run dlv debugger via VSCode and manually
  3. What did you expect to see?
    Debugger is working for my project.
  4. What did you see instead?
    The following error:
2024-08-20T21:03:44+02:00 error layer=debugger error loading binary "/Users/mariiak/repos/mycli/__debug_bin2843838000": error reading debug_info: decoding dwarf section info at offset 0x942ab7: DW_FORM_strx with no .debug_str_offsets section
could not launch process: error reading debug_info: decoding dwarf section info at offset 0x942ab7: DW_FORM_strx with no .debug_str_offsets section

I wasn't able to dissect what exactly is causing the issue - any directions are appreciated!

I also found this issue with similar problem that is happening on MacOS 15 Beta mattn/go-sqlite3#1269

@aarzilli
Copy link
Member

Can you upload a binary that shows this problem? You can do it by building with go build -gcflags='all=-N -l' and then verifying that it doesn't work by using dlv exec executable_name.

@cherrymui I think there might be new problems with the dsymutil of macOS 15, are you already aware?

@Jasstkn
Copy link
Author

Jasstkn commented Aug 21, 2024

@aarzilli Hi! Followed you guidance but dlv exec still produces the same error. Here is the binary.
helloworld.zip

@cherrymui
Copy link

What is the C toolchain you're using, and what version? E.g. the output of clang -v, ld -v, and dsymutil -v? Thanks.

@Jasstkn
Copy link
Author

Jasstkn commented Aug 22, 2024

@cherrymui hi. here you go:

❯ clang -v
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

❯ ld -v
@(#)PROGRAM:ld PROJECT:ld-1115.7.3
BUILD 07:00:06 Aug 10 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.

@AntonPieper
Copy link

I have the same exact issue. Also running macOS 15.0 Beta (24A5327a). My clang, ld and dsymutil is also 16.0.0. I get the same DW_FORM_strx with no .debug_str_offsets section error when trying to debug a single file with a sqlite3 dependency.

@Jasstkn
Copy link
Author

Jasstkn commented Aug 27, 2024

Hello @cherrymui. Do you have any update on this issue? It impacts my ability to debug go code. If there any workarounds available, please advise 🙏🏻

@cherrymui
Copy link

I don't think the Go toolchain generate DW_FORM_strx. So I guess the (new version of the) C toolchain starts to generate such entries, and Delve doesn't understand?

DW_FORM_strx with no .debug_str_offsets section

This particular error looks like https://cs.opensource.google/go/go/+/master:src/debug/dwarf/entry.go;l=670 . Maybe Go's debug/dwarf package misses something?

Do the system dwarfdump and lldb accept the binary, or complain any malformed DWARF? You probably need to build with -ldflags=-compressdwarf=0 for the Mac system tools to understand its DWARF.

@aarzilli
Copy link
Member

This is interesting. The name of sections in Mach-O executables is limited to 16 characters, apparently (if there is a way to store longer section names, somehow, I can't find it and debug/macho doesn't do it).
Because __zdebug_str_offsets is longer than 16 it gets truncated to __zdebug_str_off, which debug/dwarf does not recognize (see $GOROOT/src/debug/macho/file.go:651 and related).

@aarzilli
Copy link
Member

PS the fix for this is going to be 🤮

aarzilli added a commit to aarzilli/delve that referenced this issue Aug 27, 2024
Go 1.23 and earlier does not take into account that Mach-O section
names are limited to 16 characters, which causes DWARF sections with
long names to be truncated and become unreadable.

Fixes go-delve#3797
@cherrymui
Copy link

Interesting. Could we have debug/dwarf understand __zdebug_str_off as __zdebug_str_offsets? (If it is not ambiguous?)

@aarzilli
Copy link
Member

@Jasstkn @AntonPieper can one of you test if #3799 fixes the problem?

@cherrymui If the fix works I'll make something for the standard library, although it seems to me that this belongs more to debug/macho.(*File).DWARF.

@Jasstkn
Copy link
Author

Jasstkn commented Aug 27, 2024

@Jasstkn @AntonPieper can one of you test if #3799 fixes the problem?

@cherrymui If the fix works I'll make something for the standard library, although it seems to me that this belongs more to debug/macho.(*File).DWARF.

I built dlv from your commit and it looks like I can no longer reproduce the issue - the same binary as I attached above started to work with dlv.

./dlv version
Delve Debugger
Version: 1.23.0
Build: 1ac48d1051db06b1c5897eb8898033a0ed0717df

./dlv exec ../../../src/jasstkn/hello-world/helloworld
Type 'help' for list of commands.
(dlv)

aarzilli added a commit to aarzilli/delve that referenced this issue Aug 28, 2024
Go 1.23 and earlier does not take into account that Mach-O section
names are limited to 16 characters, which causes DWARF sections with
long names to be truncated and become unreadable.

Fixes go-delve#3797
@Psykepro
Copy link

Psykepro commented Aug 29, 2024

Guys I'm with M3 Max chip and receive the same errors by trying to run the following code:

package main

import (
	"log/slog"

	"github.com/ethereum/go-ethereum/core/types"
)

func main() {
	block := types.Block{}
	slog.Info(block)
}

Just by importing anything from go-ethereum I receive the following error on trying to debug with dlv:
Failed to launch: could not launch process: error reading debug_info: decoding dwarf section info at offset 0x98aac: DW_FORM_strx with no .debug_str_offsets section

Here are which version I'm using:
GoLang:

go version go1.23.0 darwin/arm64

dlv:

Delve Debugger
Version: 1.23.0
Build: $Id: e673f2da02185a1c2b6dea52842b0a8c7e7a03b9

go-ethereum:

require github.com/ethereum/go-ethereum v1.13.1

Please help me fix this.

gopherbot pushed a commit to golang/go that referenced this issue Aug 30, 2024
The Mach-O file format truncates section names to 16 characters
maximum, which makes some sections unrecognizable to debug/dwarf.
This CL works around this problem by re-expanding the truncated section
names.

This problem was originally reported as:
go-delve/delve#3797

Change-Id: I8c4a02493b8d5c3f63c831da43f6292124edf670
Reviewed-on: https://go-review.googlesource.com/c/go/+/608995
Auto-Submit: Ian Lance Taylor <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
@cpeliciari
Copy link

I'm even using macOS 15.1 Beta, I reinstalled the system and the problem persists.
I suggest using devcontainer for development until this is fixed.

API server listening at: 127.0.0.1:54312
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1600.0.36.3
 for arm64.
Got a connection, launched process /Users/peliciari/Library/Caches/JetBrains/GoLand2024.2/tmp/GoLand/___go_build_github_com_flamingotv_broker (pid = 18073).
2024-09-01T22:49:15-03:00 error layer=debugger error loading binary "/Users/peliciari/Library/Caches/JetBrains/GoLand2024.2/tmp/GoLand/___go_build_github_com_flamingotv_broker": error reading debug_info: decoding dwarf section info at offset 0x50d5af: DW_FORM_strx with no .debug_str_offsets section
Exiting.
could not launch process: error reading debug_info: decoding dwarf section info at offset 0x50d5af: DW_FORM_strx with no .debug_str_offsets section

@cpeliciari
Copy link

@aarzilli I tested your solution but it didn't work

@aarzilli
Copy link
Member

aarzilli commented Sep 2, 2024

@cpeliciari GoLand uses it's own copy of dlv, you have to replace it, it's inside the GoLand directory somewhere.

@Psykepro
Copy link

Psykepro commented Sep 2, 2024

@aarzilli your fix works. Sorry for not testing it before :D I guess this fix will be released with the next version?

@cpeliciari
Copy link

@aarzilli Apparently, when starting the debug session, I need to manually resume it through GoLand, whereas before it would just go straight to the breakpoint.

Screenshot 2024-09-02 at 09 35 57

Screenshot 2024-09-02 at 09 37 22

derekparker pushed a commit that referenced this issue Sep 3, 2024
Go 1.23 and earlier does not take into account that Mach-O section
names are limited to 16 characters, which causes DWARF sections with
long names to be truncated and become unreadable.

Fixes #3797
@siennathesane
Copy link

For Goland users, here's the quick fix:

GOBIN=/Users/$USER/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm go install github.com/go-delve/delve/cmd/dlv@b9fadba

image

image

@nadeemc
Copy link

nadeemc commented Sep 19, 2024

For Goland users, here's the quick fix:

GOBIN=/Users/$USER/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm go install github.com/go-delve/delve/cmd/dlv@b9fadba

Thank you for sharing! For those having the application installed for all users, you may need to run this instead:

GOBIN=/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm go install github.com/go-delve/delve/cmd/dlv@master

@ubeyali
Copy link

ubeyali commented Sep 19, 2024

For Goland users, here's the quick fix:

GOBIN=/Users/$USER/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm go install github.com/go-delve/delve/cmd/dlv@b9fadba

Thank you for sharing! For those having the application installed for all users, you may need to run this instead:

GOBIN=/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm go install github.com/go-delve/delve/cmd/dlv@master

That works for me. Thanks!

@shawnzxx
Copy link

shawnzxx commented Sep 23, 2024

The above solution works for me,
Goland folder macarm doesn't have dlv file caused the issue,
I don't know why the file was removed after I upgraded the Mac OS.
Anyway I manually copied from /Users/shawnzhang/go/bin/dlv back to amcarm folder, and solved GoLand IDE debugger.

@s0xzwasd
Copy link

GoLand team released 2024.2.2.1 version of GoLand that includes the latest Delve version with the fix. You may consider updating the IDE instead of replacing Delve binary manually.

@TelenLiu
Copy link

TelenLiu commented Oct 7, 2024

MacOS 15, GoLand team released 2024.2.3, use (https://github.com/djimenez/iconv-go | https://github.com/faiface/beep | https://github.com/shirou/gopsutil/v3)will error like:

Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.
Exiting.
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)

@GrisaiaEvy
Copy link

MacOS 15, GoLand team released 2024.2.3, use (https://github.com/djimenez/iconv-go | https://github.com/faiface/beep | https://github.com/shirou/gopsutil/v3)will error like:

Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation. Exiting. 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)

Have you solved this problem?

@s0xzwasd
Copy link

s0xzwasd commented Oct 9, 2024

could not find rodata struct member

can you reproduce it with 1.23 version of Go?

@akbarchandanianz
Copy link

MacOS 15, GoLand team released 2024.2.3, use (https://github.com/djimenez/iconv-go | https://github.com/faiface/beep | https://github.com/shirou/gopsutil/v3)will error like:

Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation. Exiting. 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)

Have you able to resolve this issue?

@FatIgor
Copy link

FatIgor commented Oct 17, 2024

I get much the same as above, have been since I started learning go for a side project.

API server listening at: 127.0.0.1:49730
debugserver-@(#)PROGRAM:LLDB PROJECT:lldb-1600.0.36.3
for arm64.
Got a connection, launched process /Users/fatigor/Library/Caches/JetBrains/GoLand2024.2/tmp/GoLand/__1go_build_Tree_Demo__1 (pid = 2688).
Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.
Exiting.
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)

@taitelman
Copy link

taitelman commented Oct 21, 2024

I got a tougher problem: also Upgraded macOS to Sequoia 15.0.1
my GoLand dlv is installed in /Applications/GoLand.app/Contents/plugins/go/lib/dlv/macarm/
and

$ sudo GOBIN=/Applications/GoLand.app/Contents/plugins/go/lib/dlv/macarm/  go install github.com/go-delve/delve/cmd/dlv@master
Password:
github.com/go-delve/delve/cmd/dlv: go install github.com/go-delve/delve/cmd/dlv: copying /tmp/go-build3874712439/b001/exe/a.out: open /Applications/GoLand.app/Contents/plugins/go/lib/dlv/macarm/dlv: operation not permitted

so I went to System Preferences --> Privacy & Security --> Full Disk Access --> enable radio button for terminal app. re-run the copy command in terminal (which works now).
Nevetheless , GoLand 2022 still fails in the same way. editing bin/idea.properties#dlv.path will have nil effect too.
I get now:

Cannot find the Delve executable for darwin/arm64. Specify the Delve location by adding 'dlv.path=/path/to/delve' in 'Help | Edit Custom Properties'.

then I discovered I edited the wrong properties file
I should add the dlv path in goland.vmoptions file as a custom VM option and add -Ddlv.path=.... and not as standard custom option.

still facing Warning: no debug info found,
solved by installing Go v1.23

@yuyinweiliao
Copy link

For Goland users, here's the quick fix:

GOBIN=/Users/$USER/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm go install github.com/go-delve/delve/cmd/dlv@b9fadba

Thank you for sharing! For those having the application installed for all users, you may need to run this instead:

GOBIN=/Applications/GoLand.app/Contents/plugins/go-plugin/lib/dlv/macarm go install github.com/go-delve/delve/cmd/dlv@master

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.