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: makeslice: cap out of range #47455

Open
RaynorGu opened this issue Jul 29, 2021 · 4 comments
Open

cmd/link: panic: runtime error: makeslice: cap out of range #47455

RaynorGu opened this issue Jul 29, 2021 · 4 comments
Labels

Comments

@RaynorGu
Copy link

@RaynorGu RaynorGu commented Jul 29, 2021

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

$ go version
go version go1.16.6 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/raynor/.cache/go-build"
GOENV="/home/raynor/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/raynor/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/raynor/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.6"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/raynor/git/go_shared_build/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1655817667=/tmp/go-build -gno-record-gcc-switches"

What did you do?

raynor@DESKTOP-7TTOU8H:~/git/go_shared_build$ go install -buildmode=shared -linkshared std
raynor@DESKTOP-7TTOU8H:~/git/go_shared_build$
raynor@DESKTOP-7TTOU8H:~/git/go_shared_build$ go install -buildmode=shared -linkshared shared/pkg0
# /tmp/go-build2695248807/b002/libshared-pkg0.so
panic: runtime error: makeslice: cap out of range

goroutine 1 [running]:
cmd/link/internal/loader.(*Loader).LoadSyms(0xc000700000, 0x87f340)
        /usr/local/go/src/cmd/link/internal/loader/loader.go:2188 +0x125
cmd/link/internal/ld.(*Link).loadlib(0xc00014e000)
        /usr/local/go/src/cmd/link/internal/ld/lib.go:558 +0x3de
cmd/link/internal/ld.Main(0x87f340, 0x20, 0x20, 0x1, 0x7, 0x10, 0x0, 0x0, 0x6e86a7, 0x1b, ...)
        /usr/local/go/src/cmd/link/internal/ld/main.go:244 +0xdbc
main.main()
        /usr/local/go/src/cmd/link/main.go:68 +0x258
raynor@DESKTOP-7TTOU8H:~/git/go_shared_build$ go list ./...
shared
shared/pkg0
shared/pkg1
raynor@DESKTOP-7TTOU8H:~/git/go_shared_build$ cat pkg0/pkg0.go
package pkg0

var (
  X int
  Y int
)

func Init() {
  X = 1
  Y = 2
}

What did you expect to see?

raynor@DESKTOP-7TTOU8H:~/git/go_shared_build$ go install -buildmode=shared -linkshared shared/pkg0
# /tmp/go-build2695248807/b002/libshared-pkg0.so
panic: runtime error: makeslice: cap out of range

goroutine 1 [running]:
cmd/link/internal/loader.(*Loader).LoadSyms(0xc000700000, 0x87f340)
        /usr/local/go/src/cmd/link/internal/loader/loader.go:2188 +0x125
cmd/link/internal/ld.(*Link).loadlib(0xc00014e000)
        /usr/local/go/src/cmd/link/internal/ld/lib.go:558 +0x3de
cmd/link/internal/ld.Main(0x87f340, 0x20, 0x20, 0x1, 0x7, 0x10, 0x0, 0x0, 0x6e86a7, 0x1b, ...)
        /usr/local/go/src/cmd/link/internal/ld/main.go:244 +0xdbc
main.main()
        /usr/local/go/src/cmd/link/main.go:68 +0x258

What did you see instead?

install success

@mengzhuo
Copy link
Contributor

@mengzhuo mengzhuo commented Jul 31, 2021

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 31, 2021

Change https://golang.org/cl/338831 mentions this issue: cmd/link: do not load symbols if size is 0

@grolfcry
Copy link

@grolfcry grolfcry commented Oct 13, 2021

Close to #47183 and #42189 or similar: receiving error "panic: runtime error: makeslice: cap out of range" when trying to install with buildmode=shared

I successfully reproduce error on go v1.16.0 (1,6,9), 1.17.2 in docker env golang:1.x.x-stretch. And it's correctly worked on 1.14.15, 1.15.15.
And it's correlated with that @mengzhuo said before - this changes has been made since 1.16.x tag.
5402d40

@mengzhuo
Copy link
Contributor

@mengzhuo mengzhuo commented Oct 14, 2021

Kindly cc @cherrymui

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

Successfully merging a pull request may close this issue.

None yet
5 participants