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/go: build -buildmode=plugin -linkshared panic: slice bounds out of range #34347

Open
vmarkovtsev opened this issue Sep 17, 2019 · 5 comments

Comments

@vmarkovtsev
Copy link

commented Sep 17, 2019

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

Tested on:

  • 1.11.13 linux/amd64
  • 1.12.9 linux/amd64
  • 1.13 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

Inside TravisCI's "xenial" dist. It also reproduces on my local machine.

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/travis/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/travis/gopath"
GOPROXY=""
GORACE=""
GOROOT="/home/travis/.gimme/versions/go1.11.13.linux.amd64"
GOTMPDIR=""
GOTOOLDIR="/home/travis/.gimme/versions/go1.11.13.linux.amd64/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build631088280=/tmp/go-build -gno-record-gcc-switches"

What did you do?

git clone https://github.com/vmarkovtsev/hercules -b reproduce-panic
cd hercules && make
./hercules generate-plugin -n MyPlug -o myplug && cd myplug && make
# runs: go build -buildmode=plugin -linkshared my_plug.go my_plug.pb.go

What did you expect to see?

The built my_plug.so.

What did you see instead?

panic: runtime error: slice bounds out of range [:-2]
goroutine 1 [running]:
cmd/go/internal/load.(*Package).load(0xc0002da900, 0xc000299668, 0xc000453180, 0x0, 0x0)
	/usr/local/go/src/cmd/go/internal/load/pkg.go:1491 +0x36db
cmd/go/internal/load.loadImport(0x0, 0xc00047d781, 0x1e, 0xc000554f00, 0x38, 0xc0000c3680, 0xc000299668, 0xc0000b80f0, 0x2, 0x2, ...)
	/usr/local/go/src/cmd/go/internal/load/pkg.go:511 +0xdf2
cmd/go/internal/load.LoadImport(0xc00047d781, 0x1e, 0xc000554f00, 0x38, 0xc0000c3680, 0xc000299668, 0xc0000b80f0, 0x2, 0x2, 0x1, ...)
	/usr/local/go/src/cmd/go/internal/load/pkg.go:464 +0xaa
cmd/go/internal/load.(*Package).load(0xc0000c3680, 0xc000299668, 0xc000088700, 0x0, 0x0)
	/usr/local/go/src/cmd/go/internal/load/pkg.go:1605 +0x1993
cmd/go/internal/load.GoFilesPackage(0xc0000b6160, 0x2, 0x2, 0x4d3c01)
	/usr/local/go/src/cmd/go/internal/load/pkg.go:2130 +0x543
cmd/go/internal/load.PackagesAndErrors(0xc0000b6160, 0x2, 0x2, 0x0, 0x0, 0x0)
	/usr/local/go/src/cmd/go/internal/load/pkg.go:1956 +0x6ca
cmd/go/internal/load.PackagesForBuild(0xc0000b6160, 0x2, 0x2, 0xa3a450, 0x2, 0x1)
	/usr/local/go/src/cmd/go/internal/load/pkg.go:2023 +0x5d
cmd/go/internal/work.runBuild(0xea4280, 0xc0000b6160, 0x2, 0x2)
	/usr/local/go/src/cmd/go/internal/work/build.go:316 +0x88
main.main()
	/usr/local/go/src/cmd/go/main.go:189 +0x57f

Notes

This used to work fine without go modules.

@toothrot toothrot changed the title `go build -buildmode=plugin -linkshared` panic: slice bounds out of range x/build: -buildmode=plugin -linkshared panic: slice bounds out of range Sep 17, 2019
@gopherbot gopherbot added this to the Unreleased milestone Sep 17, 2019
@gopherbot gopherbot added the Builders label Sep 17, 2019
@toothrot

This comment has been minimized.

Copy link
Contributor

commented Sep 17, 2019

Although the failure message is different, I feel like the following comment still applies: #18671

I don't expect -buildmode=plugin -linkshared to work today. Somebody will have to investigate the problems and figure out whether they can be fixed. I don't know of anybody planning to do that.

I'm going to close this as a duplicate of #18671, but please comment if you disagree or if you feel that I misunderstood the issue.

@toothrot toothrot closed this Sep 17, 2019
@vmarkovtsev

This comment has been minimized.

Copy link
Author

commented Sep 17, 2019

It works if I build everything "old style" inside a GOPATH. This panic happens only when I turn the modules on.

@toothrot toothrot changed the title x/build: -buildmode=plugin -linkshared panic: slice bounds out of range cmd/go: build -buildmode=plugin -linkshared panic: slice bounds out of range Sep 18, 2019
@toothrot toothrot removed the Builders label Sep 18, 2019
@toothrot toothrot modified the milestones: Unreleased, Go1.14 Sep 18, 2019
@toothrot

This comment has been minimized.

Copy link
Contributor

commented Sep 18, 2019

@vmarkovtsev Thanks for the follow-up. I could be wrong about this for sure.

/cc @ianlancetaylor who was the author of the comment I quoted about buildmode=plugin -linkshared

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Sep 18, 2019

Yes, I think this is a different issue, and we should leave this open separately.

But I also think that what I wrote earlier applies: I don't expect -buildmode=plugin -linkshared to work today. Somebody will have to investigate the problems and figure out whether they can be fixed. I don't know of anybody planning to do that.

I encourage you to investigate the problem and send a fix.

@benkard

This comment has been minimized.

Copy link

commented Oct 16, 2019

For what it's worth, this is not limited to -buildmode=plugin. The same happens for me when I try to build a simple hello-world program with one go mod dependency (Go 1.13.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.