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

debug/elf: opening ELF binary with detached debug symbols results in panic #63837

Closed
benbaker76 opened this issue Oct 31, 2023 · 1 comment
Closed
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@benbaker76
Copy link

benbaker76 commented Oct 31, 2023

What version of Go are you using (go version)?

$ go version
go version go1.21.3 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/bbaker/.cache/go-build'
GOENV='/home/bbaker/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/bbaker/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/bbaker/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/bbaker/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/bbaker/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/bbaker/Programming/bpf/libbpf-tools/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3402554320=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I want to examine an ELF binary with detached debug symbols. I was looking for the offset and size of _int_malloc in /usr/lib/x86_64-linux-gnu/libc.so.6.

$ readelf -sW /usr/lib/x86_64-linux-gnu/libc.so.6 | grep _int_malloc
$ readelf --notes /usr/lib/x86_64-linux-gnu/libc.so.6 | grep -A 3 .note.gnu.build-id
Displaying notes found in: .note.gnu.build-id
  Owner                Data size 	Description
  GNU                  0x00000014	NT_GNU_BUILD_ID (unique build ID bitstring)
    Build ID: ff2d8e707625b73b293961a4bc168e373d14a44a
$ dwarfdump --print-debug-names /usr/lib/x86_64-linux-gnu/libc.so.6
Filename by debuglink is /usr/lib/debug/.build-id/ff/2d8e707625b73b293961a4bc168e373d14a44a.debug

.note.gnu.build-id
 Build-id  type     : 3
 Build-id  ownername: GNU
 Build-id  length   : 20
 Build-id           : ff2d8e707625b73b293961a4bc168e373d14a44a
 Possible .gnu_debuglink/.note.gnu.build-id pathnames for
 an alternate object file with more detailed DWARF
  [0] /usr/lib/debug/.build-id/ff/2d8e707625b73b293961a4bc168e373d14a44a.debug
       file above is an Elf object
$ readelf -sW /usr/lib/debug/.build-id/ff/2d8e707625b73b293961a4bc168e373d14a44a.debug | grep _int_malloc
readelf: Error: Unable to find program interpreter name
  1331: 000000000009e360  3738 FUNC    LOCAL  DEFAULT   16 _int_malloc
f, err := elf.Open("/usr/lib/debug/.build-id/ff/2d8e707625b73b293961a4bc168e373d14a44a.debug")
if err != nil {
	fmt.Println("Error opening ELF:", err)
	return
}
defer f.Close()

What did you expect to see?

I should be able to view the debug info in the ELF file.

What did you see instead?

panic: interface conversion: interface {} is nil, not uint64

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Oct 31, 2023
@mauri870 mauri870 added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 31, 2023
@benbaker76 benbaker76 changed the title debug/elf: opening ELF binary with detached debug symbols results in exit status 1 debug/elf: opening ELF binary with detached debug symbols results in error Nov 1, 2023
@benbaker76 benbaker76 changed the title debug/elf: opening ELF binary with detached debug symbols results in error debug/elf: opening ELF binary with detached debug symbols results in panic Nov 1, 2023
@benbaker76
Copy link
Author

Turns out it's an issue in my code that was not showing up due to a deferred os.Exit(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants