Skip to content

debug/elf: calling Open on an empty file does not return a &FormatError #76338

@MusicalNinjaDad

Description

@MusicalNinjaDad

Go version

go1.24.9 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/ninjacoder/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/ninjacoder/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2922389718=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/workspaces/snaggle/go.mod'
GOMODCACHE='/workspaces/snaggle/.go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/workspaces/snaggle/.go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/usr/lib/golang'
GOSUMDB='off'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/ninjacoder/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.9'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

shell: touch .empty

elffile, err = debug_elf.Open(".empty")

What did you see happen?

err is a naked io.EOF and not a &FormatError as would be expected. i.e.:

errors.Is(err, io.EOF) == true
var formaterr *debug_elf.FormatError
errors.As(err, &formaterr) == false

What did you expect to see?

As with other errors encountered by Open a &FormatError should be returned. Probably &FormatError{0, "no data"}

See MusicalNinjaDad/snaggle@3c69325#L172

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.compiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions