Skip to content

debug/pe: slice bounds out of range panic #73548

@monoidic

Description

@monoidic

Go version

go version go1.24.2 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/user/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build890824037=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/snap/go/10888'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/snap/go/10888/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I attempted to automatically analyze the executables on a Windows host. As a part of that, debug/pe.File.ImportedSymbols() was called.
This failed on the official Windows Word .exe file with a "slice bounds out of range" error.
https://go.dev/play/p/K1_mQcc4Fbd
Minimal example which produces the same error with just the first 32k bytes of winword.exe.
If required, I can share the full file itself as well. Though I am not 100% sure about the licensing terms of sharing winword.exe

What did you see happen?

Slice bounds out of error panic, as is visible in the Go Playground link.

panic: runtime error: slice bounds out of range [4294947512:512]

goroutine 1 [running]:
debug/pe.(*File).ImportedSymbols(0x50a608?)
	/usr/local/go-faketime/src/debug/pe/file.go:411 +0x949
main.main()
	/tmp/sandbox1960551843/prog.go:16 +0x186

What did you expect to see?

A slice with the names of the symbols, as the documentation states.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions