delve
delve copied to clipboard
[delve/pkg/dwarf] panic: runtime error: slice bounds out of range
For certain applications, Delve is panicking when I attempt to debug. This issue is only present for some of my go projects, some applications I can debug without issue.
- What version of Delve are you using (
dlv version)?
Delve Debugger
Version: 1.23.1
Build: $Id: 2eba762d75437d380e48fc42213853f13aa2904d $
- What version of Go are you using? (
go version)?
go version go1.23.3 darwin/arm64
- What operating system and processor architecture are you using?
darwin/arm64 (MacOS)
- What did you do?
❯ dlv debug cmd/server/main.go
- What did you expect to see?
Type 'help' for list of commands.
(dlv)
- What did you see instead?
panic: runtime error: slice bounds out of range [74:0]
goroutine 7 [running]:
github.com/go-delve/delve/pkg/dwarf/line.parseIncludeDirs5(0x14003cc3810, 0x1400419d1a0)
REDACTED/go/1.23.3/pkg/mod/github.com/go-delve/[email protected]/pkg/dwarf/line/line_parser.go:188 +0x460
github.com/go-delve/delve/pkg/dwarf/line.Parse({0x14006b3e630, 0xd}, 0x1400419d1a0, {0x0, 0x0, 0x0}, 0x0, 0x76c000, 0x0, 0x8)
REDACTED/go/1.23.3/pkg/mod/github.com/go-delve/[email protected]/pkg/dwarf/line/line_parser.go:100 +0x23c
github.com/go-delve/delve/pkg/proc.(*BinaryInfo).loadDebugInfoMaps(0x1400023e000, 0x140016bc000, {0x14003c42000, 0x9b6289, 0x9b6289}, {0x14004768000, 0x6cf93a, 0x6cf93a}, 0x140016943c0, 0x14000242200)
REDACTED/go/1.23.3/pkg/mod/github.com/go-delve/[email protected]/pkg/proc/bininfo.go:2478 +0x7a8
created by github.com/go-delve/delve/pkg/proc.loadBinaryInfoMacho in goroutine 1
REDACTED/go/1.23.3/pkg/mod/github.com/go-delve/[email protected]/pkg/proc/bininfo.go:2017 +0x590
Also, here is my go env
GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='REDACTED/Library/Caches/go-build'
GOENV='REDACTED/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='REDACTED/go/1.23.3/pkg/mod'
GONOPROXY=''
GONOSUMDB=REDACTED
GOOS='darwin'
GOPATH='REDACTED/go/1.23.3'
GOPRIVATE=''
GOPROXY=REDACTED
GOROOT='REDACTED/.goenv/versions/1.23.3'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='REDACTED/.goenv/versions/1.23.3/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.3'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='REDACTED/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='/usr/local/bin/gcc'
CXX='/usr/bin/g++'
CGO_ENABLED='1'
GOMOD='REDACTED/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 -fmessage-length=0 -ffile-prefix-map=/var/folders/p2/r1fr92ns20dggzgnmv20w1p80000gn/T/go-build3234217224=/tmp/go-build -gno-record-gcc-switches -fno-common'
I notice here that MacOS darwin/arm64 is not on the supported list. Could this be the issue, and if so, is there a plan to support Apple's M series of processors?
Update, setting CGO_ENABLED=0 seems to provide a fix for projects that don't require it
Darwin/arm64 is supported. There is probably a bug in our implementation of DWARFv5, it would be very helpful if you could share the binary file that produces this error, even privately. Alternatively can you post the output of dlv debug --log --log-output=debugger ... as well as use go build -gcflags='all=-N -l' -o executable ... to compile and then run otool -l executable.
Will send logs shortly
Unfortunately, because the issue is occurring when debugging internal software at my company, I cannot provide anything beyond what I have already shared.
Not even the names of the sections returned by otool -l? I'd have to close this as not-reproducible.
Let me check
executablecmd/server/main.go:
Load command 0
cmd LC_SEGMENT_64
cmdsize 72
segname __PAGEZERO
vmaddr 0x0000000000000000
vmsize 0x0000000100000000
fileoff 0
filesize 0
maxprot 0x00000000
initprot 0x00000000
nsects 0
flags 0x0
Load command 1
cmd LC_SEGMENT_64
cmdsize 552
segname __TEXT
vmaddr 0x0000000100000000
vmsize 0x0000000001e84000
fileoff 0
filesize 31997952
maxprot 0x00000005
initprot 0x00000005
nsects 6
flags 0x0
Section
sectname __text
segname __TEXT
addr 0x00000001000047a0
size 0x0000000001879560
offset 18336
align 2^5 (32)
reloff 0
nreloc 0
flags 0x80000400
reserved1 0
reserved2 0
Section
sectname __stubs
segname __TEXT
addr 0x000000010187dd00
size 0x0000000000000840
offset 25681152
align 2^2 (4)
reloff 0
nreloc 0
flags 0x80000408
reserved1 0 (index into indirect symbol table)
reserved2 12 (size of stubs)
Section
sectname __rodata
segname __TEXT
addr 0x000000010187e540
size 0x0000000000601d35
offset 25683264
align 2^5 (32)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __cstring
segname __TEXT
addr 0x0000000101e80278
size 0x0000000000000405
offset 31982200
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000002
reserved1 0
reserved2 0
Section
sectname __const
segname __TEXT
addr 0x0000000101e80680
size 0x00000000000002f8
offset 31983232
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __eh_frame
segname __TEXT
addr 0x0000000101e80978
size 0x0000000000003678
offset 31983992
align 2^3 (8)
reloff 0
nreloc 0
flags 0x6800000b
reserved1 0
reserved2 0
Load command 2
cmd LC_SEGMENT_64
cmdsize 632
segname __DATA_CONST
vmaddr 0x0000000101e84000
vmsize 0x0000000001048000
fileoff 31997952
filesize 17072128
maxprot 0x00000003
initprot 0x00000003
nsects 7
flags 0x10
Section
sectname __got
segname __DATA_CONST
addr 0x0000000101e84000
size 0x00000000000005a0
offset 31997952
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000006
reserved1 176 (index into indirect symbol table)
reserved2 0
Section
sectname __const
segname __DATA_CONST
addr 0x0000000101e845a0
size 0x0000000000000010
offset 31999392
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __cfstring
segname __DATA_CONST
addr 0x0000000101e845b0
size 0x0000000000000040
offset 31999408
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __rodata
segname __DATA_CONST
addr 0x0000000101e84600
size 0x000000000052f580
offset 31999488
align 2^5 (32)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __typelink
segname __DATA_CONST
addr 0x00000001023b3b80
size 0x000000000000ec3c
offset 37436288
align 2^5 (32)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __itablink
segname __DATA_CONST
addr 0x00000001023c27c0
size 0x00000000000059d0
offset 37496768
align 2^5 (32)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __gopclntab
segname __DATA_CONST
addr 0x00000001023c81a0
size 0x0000000000b010a8
offset 37519776
align 2^5 (32)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Load command 3
cmd LC_SEGMENT_64
cmdsize 552
segname __DATA
vmaddr 0x0000000102ecc000
vmsize 0x00000000001f8000
fileoff 49070080
filesize 1703936
maxprot 0x00000003
initprot 0x00000003
nsects 6
flags 0x0
Section
sectname __data
segname __DATA
addr 0x0000000102ecc000
size 0x000000000003b360
offset 49070080
align 2^5 (32)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __go_buildinfo
segname __DATA
addr 0x0000000102f07360
size 0x00000000000040c0
offset 49312608
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __noptrdata
segname __DATA
addr 0x0000000102f0b420
size 0x000000000015fc49
offset 49329184
align 2^5 (32)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __bss
segname __DATA
addr 0x000000010306b080
size 0x000000000003fbbc
offset 0
align 2^5 (32)
reloff 0
nreloc 0
flags 0x00000001
reserved1 0
reserved2 0
Section
sectname __noptrbss
segname __DATA
addr 0x00000001030aac40
size 0x0000000000019100
offset 0
align 2^5 (32)
reloff 0
nreloc 0
flags 0x00000001
reserved1 0
reserved2 0
Section
sectname __common
segname __DATA
addr 0x00000001030c3d40
size 0x0000000000000060
offset 0
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000001
reserved1 0
reserved2 0
Load command 4
cmd LC_SEGMENT_64
cmdsize 72
segname __LINKEDIT
vmaddr 0x00000001030c4000
vmsize 0x00000000005a8982
fileoff 58441728
filesize 5933442
maxprot 0x00000001
initprot 0x00000001
nsects 0
flags 0x0
Load command 5
cmd LC_DYLD_CHAINED_FIXUPS
cmdsize 16
dataoff 58441728
datasize 4024
Load command 6
cmd LC_DYLD_EXPORTS_TRIE
cmdsize 16
dataoff 58445752
datasize 3280
Load command 7
cmd LC_SYMTAB
cmdsize 24
symoff 58546560
nsyms 70302
stroff 59672816
strsize 4203200
Load command 8
cmd LC_DYSYMTAB
cmdsize 80
ilocalsym 0
nlocalsym 69990
iextdefsym 69990
nextdefsym 131
iundefsym 70121
nundefsym 181
tocoff 0
ntoc 0
modtaboff 0
nmodtab 0
extrefsymoff 0
nextrefsyms 0
indirectsymoff 59671392
nindirectsyms 356
extreloff 0
nextrel 0
locreloff 0
nlocrel 0
Load command 9
cmd LC_LOAD_DYLINKER
cmdsize 32
name /usr/lib/dyld (offset 12)
Load command 10
cmd LC_UUID
cmdsize 24
uuid DBB859D1-3AC5-3987-C72A-0927B6872F4D
Load command 11
cmd LC_BUILD_VERSION
cmdsize 32
platform 1
minos 15.0
sdk n/a
ntools 1
tool 3
version 1115.7.3
Load command 12
cmd LC_SOURCE_VERSION
cmdsize 16
version 0.0
Load command 13
cmd LC_MAIN
cmdsize 24
entryoff 545904
stacksize 0
Load command 14
cmd LC_LOAD_DYLIB
cmdsize 56
name /usr/lib/libresolv.9.dylib (offset 24)
time stamp 2 Wed Dec 31 18:00:02 1969
current version 1.0.0
compatibility version 1.0.0
Load command 15
cmd LC_LOAD_DYLIB
cmdsize 104
name /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (offset 24)
time stamp 2 Wed Dec 31 18:00:02 1969
current version 3208.0.0
compatibility version 150.0.0
Load command 16
cmd LC_LOAD_DYLIB
cmdsize 96
name /System/Library/Frameworks/Security.framework/Versions/A/Security (offset 24)
time stamp 2 Wed Dec 31 18:00:02 1969
current version 61439.60.117
compatibility version 1.0.0
Load command 17
cmd LC_LOAD_DYLIB
cmdsize 88
name /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (offset 24)
time stamp 2 Wed Dec 31 18:00:02 1969
current version 275.0.0
compatibility version 1.0.0
Load command 18
cmd LC_LOAD_DYLIB
cmdsize 56
name /usr/lib/libSystem.B.dylib (offset 24)
time stamp 2 Wed Dec 31 18:00:02 1969
current version 1351.0.0
compatibility version 1.0.0
Load command 19
cmd LC_RPATH
cmdsize 32
path @loader_path (offset 12)
Load command 20
cmd LC_RPATH
cmdsize 96
path /opt/homebrew/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/aarch64-apple-darwin24/14 (offset 12)
Load command 21
cmd LC_RPATH
cmdsize 72
path /opt/homebrew/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc (offset 12)
Load command 22
cmd LC_RPATH
cmdsize 64
path /opt/homebrew/Cellar/gcc/14.2.0_1/lib/gcc/current (offset 12)
Load command 23
cmd LC_FUNCTION_STARTS
cmdsize 16
dataoff 58449032
datasize 97528
Load command 24
cmd LC_DATA_IN_CODE
cmdsize 16
dataoff 58546560
datasize 0
Load command 25
cmd LC_CODE_SIGNATURE
cmdsize 16
dataoff 63876016
datasize 499154
Load command 26
cmd LC_SEGMENT_64
cmdsize 1032
segname __DWARF
vmaddr 0x0000000000000000
vmsize 0x0000000000000000
fileoff 50774016
filesize 7665958
maxprot 0x00000007
initprot 0x00000000
nsects 12
flags 0x0
Section
sectname __zdebug_line
segname __DWARF
addr 0x00000001035d8000
size 0x0000000000112cd0
offset 50774016
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __zdebug_loc
segname __DWARF
addr 0x00000001036eacd0
size 0x00000000000d0f6c
offset 51899600
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __zdebug_ranges
segname __DWARF
addr 0x00000001037bbc3c
size 0x0000000000028219
offset 52755516
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __zdebug_aranges
segname __DWARF
addr 0x00000001037e3e55
size 0x0000000000002852
offset 52919893
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __zdebug_info
segname __DWARF
addr 0x00000001037e66a7
size 0x0000000000290026
offset 52930215
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __zdebug_frame
segname __DWARF
addr 0x0000000103a766cd
size 0x000000000008d53d
offset 55617229
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __zdebug_abbrev
segname __DWARF
addr 0x0000000103b03c0a
size 0x0000000000000314
offset 56196106
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __zdebug_str
segname __DWARF
addr 0x0000000103b03f1e
size 0x000000000009cbdd
offset 56196894
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __zapple_names
segname __DWARF
addr 0x0000000103ba0afb
size 0x00000000001078fa
offset 56838907
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __apple_namespac
segname __DWARF
addr 0x0000000103ca83f5
size 0x0000000000000024
offset 57918453
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __zapple_types
segname __DWARF
addr 0x0000000103ca8419
size 0x000000000007f4e9
offset 57918489
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __apple_objc
segname __DWARF
addr 0x0000000103d27902
size 0x0000000000000024
offset 58439938
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
It looks like the __zdebug_line_str has been stripped off by something, I wonder what, there might be other bugs with long section names and mach-o somewhere. Hard to know what's at fault without being able to reproduce it. Not delve's fault, however. Maybe go's linker, maybe LLVM.
I just noticed I'm hitting this error as well, which is breaking debugging in GoLand for me. If you need any additional information I'm happy to help.
go test -gcflags="all=-N -l" -c ./path/to/package -o out && otool -l out | grep debug -A 10
sectname __zdebug_line
segname __DWARF
addr 0x0000000106ddf000
size 0x00000000001d73d1
offset 99237888
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_ranges
segname __DWARF
addr 0x0000000106fb63d1
size 0x00000000000477b8
offset 101168081
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_loc
segname __DWARF
addr 0x0000000106ffdb89
size 0x00000000001d9163
offset 101460873
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_aranges
segname __DWARF
addr 0x00000001071d6cec
size 0x0000000000002b32
offset 103398636
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_info
segname __DWARF
addr 0x00000001071d981e
size 0x000000000054ef32
offset 103409694
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_frame
segname __DWARF
addr 0x0000000107728750
size 0x00000000000daf91
offset 108975952
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_abbrev
segname __DWARF
addr 0x00000001078036e1
size 0x00000000000007c4
offset 109872865
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_str
segname __DWARF
addr 0x0000000107803ea5
size 0x000000000013cb41
offset 109874853
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
$ go version
go version go1.23.2 darwin/arm64
$ which go
/opt/homebrew/bin/go
Are you also using llvm installed with homebrew? There have been problems in the past with that. Otherwise do you have a way that we can reproduce this problem?
I was using golang installed from homebrew, but the issue persists when I just download the package installer from https://go.dev/dl/
/usr/local/go/bin/go version
go version go1.24.0 darwin/arm64
clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I tried the -ldflags=-linkmode=internal flag mentioned in the linked ticket, but the build failed.
go test -gcflags="all=-N -l" -ldflags=-linkmode=internal -c ./pkg/matrix -o out
# github.com/beeper/beeper-client-sdk/pkg/matrix.test
/opt/homebrew/Cellar/go/1.24.0/libexec/pkg/tool/darwin_arm64/link: internal linking requested but external linking required: some packages could not be built to support internal linking ([go.mau.fi/mautrix-signal/pkg/libsignalgo])
Can reproduce with this repository here: https://github.com/mautrix/signal/
It's got a native rust dependency in a submodule, so initialize the submodule and then run DBG=1 ./build.sh. This will build the rust libary and then the resulting go library without stripping.
This gives me the following output:
$ otool -l ./mautrix-signal | grep debug -A 10
sectname __zdebug_line
segname __DWARF
addr 0x0000000103931000
size 0x0000000000110550
offset 50200576
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_ranges
segname __DWARF
addr 0x0000000103a41550
size 0x000000000002d120
offset 51316048
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_loc
segname __DWARF
addr 0x0000000103a6e670
size 0x00000000000f03bf
offset 51500656
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_aranges
segname __DWARF
addr 0x0000000103b5ea2f
size 0x00000000000017a9
offset 52484655
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_info
segname __DWARF
addr 0x0000000103b601d8
size 0x000000000028dddc
offset 52490712
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_frame
segname __DWARF
addr 0x0000000103dedfb4
size 0x00000000000513d0
offset 55168948
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_abbrev
segname __DWARF
addr 0x0000000103e3f384
size 0x000000000000075d
offset 55501700
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
--
sectname __zdebug_str
segname __DWARF
addr 0x0000000103e3fae1
size 0x00000000000a298e
offset 55503585
align 2^0 (1)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
cc @cherrymui it looks like sometimes DWARFv5 ends up getting used on macOS and some sections are missing from the executable, not sure where they go missing.