Skip to content

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

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

Open
monoidic opened this issue Apr 30, 2025 · 3 comments
Open

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

monoidic opened this issue Apr 30, 2025 · 3 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@monoidic
Copy link

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.

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Apr 30, 2025
@randall77
Copy link
Contributor

@alexbrainman @golang/windows

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 30, 2025
@cagedmantis cagedmantis added this to the Go1.25 milestone Apr 30, 2025
@monoidic
Copy link
Author

monoidic commented May 2, 2025

It does seem that a good number of PE parsers stumble a bit on this file, actually.
The Rust pelite library gives a "unaligned" error unless unsafe_alignment is used, disabling alignment checks.
pestudio displays garbled text.
PE-Bear and the Python pefile library seem to work just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. 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

5 participants
@cagedmantis @randall77 @monoidic @gabyhelp and others