golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.88k stars 17.52k forks source link

cmd/link/internal/loader: panic: runtime error: index out of range [1232602353] with length 116 #69214

Open krhubert opened 1 week ago

krhubert commented 1 week ago

Go version

go version go1.23.0 linux/amd64

Output of go env in your module/workspace:

GO111MODULE='auto'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/user/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org'
GOROOT='/home/user/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/user/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/user/src/project/backend/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-build356147905=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Run

go build

Can't trace this right now, and give you a reproducible source code, because I'm not sure what's the root case. I'll keep looking.

What did you see happen?

panic: runtime error: index out of range [1232602353] with length 116

goroutine 1 [running]:
cmd/link/internal/loader.(*Loader).resolve(0xc000778008?, 0x15765d0003eef9?, {0x4?, 0x0?})
        cmd/link/internal/loader/loader.go:647 +0x178
cmd/link/internal/loader.Aux.Sym(...)
        cmd/link/internal/loader/loader.go:73
cmd/link/internal/ld.(*deadcodePass).flood(0xc0000fd688)
        cmd/link/internal/ld/deadcode.go:280 +0xed4
cmd/link/internal/ld.deadcode(0xc0001a6200)
        cmd/link/internal/ld/deadcode.go:440 +0x7d
cmd/link/internal/ld.Main(_, {0x20, 0x20, 0x1, 0x7, 0x10, 0x0, {0xc000012521, 0x1, 0x1}, ...})
        cmd/link/internal/ld/main.go:360 +0x1318
main.main()
        cmd/link/main.go:72 +0xddb

What did you expect to see?

go build without errors

gabyhelp commented 1 week ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

ianlancetaylor commented 1 week ago

Has this happened more than once?

I think we're going to need a way to reproduce the problem.

krhubert commented 1 week ago

Has this happened more than once?

Yes

I think we're going to need a way to reproduce the problem.

It's gonna be extremely hard to me to reproduce it.

This happened when I worked on my project and switched between branches. On the main branch, go build returned without errors, but on other branch with a single commit added, go build panicked. Today I can't reproduce this case, but yesterday it was like that until a restarted WSL.

I'm not sure if/how I can help more. If there's not enough data to reproduce it I can close this issue.

cherrymui commented 1 week ago

Could you try clear the build cache (go clean -cache) and see if you can still reproduce?

It could be some file corruption in the build cache, or when you switched branch, there was actually some collision in the build cache.