Skip to content
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

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

Open
w01fb0ss opened this issue Sep 25, 2020 · 6 comments
Milestone

Comments

@w01fb0ss
Copy link

@w01fb0ss w01fb0ss commented Sep 25, 2020

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

@w01fb0ss
Copy link
Author

@w01fb0ss w01fb0ss commented Sep 25, 2020

$ go env

image

@davecheney
Copy link
Contributor

@davecheney davecheney commented Sep 25, 2020

@w01fb0ss please do not post screenshots of text, please just copy and paste the text. Thank you

@ianlancetaylor ianlancetaylor changed the title panic: runtime error: slice bounds out of range [::1751306] with length 1048576 cmd/link: panic: runtime error: slice bounds out of range [::1751306] with length 1048576 Sep 25, 2020
@ianlancetaylor ianlancetaylor added this to the Go1.16 milestone Sep 25, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Sep 25, 2020

@w01fb0ss
Copy link
Author

@w01fb0ss w01fb0ss commented Sep 25, 2020

$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xxx/Library/Caches/go-build"
GOENV="/Users/xxx/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/xxx/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/xxx/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn"
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="/Users/xxx/go/src/aiotools/server/go.mod"
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/13/jzs_fl_10zqbptmd_9flzr040000gn/T/go-build766193444=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you see instead?

command-line-arguments

panic: runtime error: slice bounds out of range [::1751306] with length 1048576

goroutine 1 [running]:
cmd/internal/goobj2.(*Reader).Relocs(0xc00094f710, 0x6, 0xc0000680b0, 0x2d7b, 0xc00010ec80)
/usr/local/go/src/cmd/internal/goobj2/objfile.go:655 +0xb4
cmd/link/internal/loader.(*Loader).relocs(0xc000614000, 0xc000619f80, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/cmd/link/internal/loader/loader.go:1712 +0xf0
cmd/link/internal/loader.(*Loader).Relocs(0xc000614000, 0x116e7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/cmd/link/internal/loader/loader.go:1702 +0x7d
cmd/link/internal/ld.(*deadcodePass).flood(0xc0000680a0)
/usr/local/go/src/cmd/link/internal/ld/deadcode.go:119 +0x425
cmd/link/internal/ld.deadcode(0xc00007b880)
/usr/local/go/src/cmd/link/internal/ld/deadcode.go:264 +0xcc
cmd/link/internal/ld.Main(0x14709e0, 0x20, 0x20, 0x1, 0x7, 0x10, 0x0, 0x0, 0x12d81c2, 0x1b, ...)
/usr/local/go/src/cmd/link/internal/ld/main.go:235 +0xd3c
main.main()
/usr/local/go/src/cmd/link/main.go:68 +0x1dc

@randall77
Copy link
Contributor

@randall77 randall77 commented Sep 25, 2020

@thanm
Copy link
Member

@thanm thanm commented Sep 25, 2020

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.