go-delve / delve

Delve is a debugger for the Go programming language.
MIT License
22.94k stars 2.14k forks source link

DW_FORM_strx with no .debug_str_offsets section #3797

Closed Jasstkn closed 1 month ago

Jasstkn commented 2 months ago

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 $
  2. What version of Go are you using? (go version)?
    go version go1.23.0 darwin/arm64
  3. What operating system and processor architecture are you using? MacOS on ARM, issue started to be reproduced since MacOS 15 Beta(24A5327a).
  4. What did you do? run dlv debugger via VSCode and manually
  5. What did you expect to see? Debugger is working for my project.
  6. 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 https://github.com/mattn/go-sqlite3/issues/1269

aarzilli commented 2 months ago

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 commented 2 months ago

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

cherrymui commented 2 months ago

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 commented 2 months ago

@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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

PS the fix for this is going to be 🤮

cherrymui commented 2 months ago

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

aarzilli commented 2 months ago

@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 commented 2 months ago

@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)
Psykepro commented 2 months ago

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.

cpeliciari commented 1 month ago

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 commented 1 month ago

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

aarzilli commented 1 month ago

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

Psykepro commented 1 month ago

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

cpeliciari commented 1 month ago

@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

siennathesane commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 3 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

could not find rodata struct member

can you reproduce it with 1.23 version of Go?

akbarchandanianz commented 1 week ago

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 commented 1 week ago

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_Demo1_ (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 commented 1 week ago

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