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

Closed
ray2011 opened this issue Jul 29, 2021 · 9 comments
Closed

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

ray2011 opened this issue Jul 29, 2021 · 9 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.

Comments

@ray2011
Copy link

ray2011 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 commented Jul 31, 2021

I can reproduce this issue.

It seems that

https://github.com/golang/go/blob/b7a85e0003cedb1b48a1fd3ae5b746ec6330102e/src/cmd/link/internal/loader/loader.go#L2204-#L2210

passing symSize =0 which causing this issue.

@cherrymui

@gopherbot
Copy link

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

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 1, 2021
@grolfcry
Copy link

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

Kindly cc @cherrymui

@seankhliao
Copy link
Member

Obsoleted by #47788

@alexanius
Copy link

Same issue with 1.18.3 version

@GouthamBanala
Copy link

Seeing issues on go version go1.20 linux/amd64

@logrusorgru
Copy link

Obsoleted by #47788

Isn't it declined #47788 (comment) ?

@cherrymui
Copy link
Member

Per #47788 (comment)

We've decided to leave -buildmode=shared alone (not delete it) for Go 1.18,
but it's not going to work any better than it does today.
In particular, we're not fixing any bugs in it anymore, ...

So it still applies. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

9 participants