go: cmd/link: panic: runtime error: slice bounds out of range [::1751306] with length 1048576

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

$ go version
$ go version go1.15.2 darwin/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
![image](https://user-images.githubusercontent.com/44709004/94216230-74f59580-ff11-11ea-8947-a36c8bfbf679.png)

What did you do?

$ go build -o xxx main.go

What did you expect to see?

build success

What did you see instead?

image

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Would you be able to post instructions and/or source code so that we can reproduce this?

The panic is happening while the linker is reading relocations out of an object file – the offset it reads from the file is insane, which triggers the bounds range error. It would probably be a good idea to try to rule out the possibility of a corrupted object file (e.g. go clean -cache and rebuild).

Thanks @roger6106 . I will take a look.

@thanm: I just ran into this same issue. I have included reproducible code. Run go generate and then go build.

golang-41621.zip

$ go version
go version go1.15.6 darwin/amd64
go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/roger/Library/Caches/go-build"
GOENV="/Users/roger/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/roger/go/pkg/mod"
GONOPROXY="[removed]"
GONOSUMDB="[removed]"
GOOS="darwin"
GOPATH="/Users/roger/go"
GOPRIVATE="[removed]"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_c/lb59l5wn1yv2sj3g83s0hqbm0000gn/T/go-build160846022=/tmp/go-build -gno-record-gcc-switches -fno-common"