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

Closed
vmarkovtsev opened this issue Sep 17, 2019 · 12 comments
Closed
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@vmarkovtsev
Copy link

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 x/build issues (builders, bots, dashboards) label Sep 17, 2019
@toothrot
Copy link
Contributor

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.

@vmarkovtsev
Copy link
Author

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 x/build issues (builders, bots, dashboards) label Sep 18, 2019
@toothrot toothrot modified the milestones: Unreleased, Go1.14 Sep 18, 2019
@toothrot
Copy link
Contributor

@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
Copy link
Contributor

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.

@ianlancetaylor ianlancetaylor modified the milestones: Go1.14, Unplanned Sep 18, 2019
@ianlancetaylor ianlancetaylor added help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 18, 2019
@benkard
Copy link

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

@jayconrod jayconrod modified the milestones: Unplanned, Go1.14 Nov 11, 2019
@jayconrod
Copy link
Contributor

Reprioritizing for Go1.14. This is a panic in cmd/go that happens when cfg.BuildLinkshared is set. It doesn't actually seem related to the mechanics of linking and plugins. I think we're trying to trim a so suffix from a file name that happens to be empty.

@bcmills
Copy link
Contributor

bcmills commented Nov 21, 2019

I'm not able to reproduce this specific failure mode. However, I have a fix for #35759, which seems closely related.

@gopherbot
Copy link

Change https://golang.org/cl/208233 mentions this issue: cmd/go: do not panic when computing Shlib for a package with no Target

@gopherbot
Copy link

Change https://golang.org/cl/208458 mentions this issue: cmd/go/internal/work: reduce code duplication in buildModeInit by using sys.BuildModeSupported

gopherbot pushed a commit that referenced this issue Nov 22, 2019
In module mode, a non-main package lacks an install target.

The location of the .shlib corresponding to a given target is stored
in a .shlibname file alongside its install target, so in module mode
a non-main package also lacks a .shlibname file.

This also implies that such a package cannot be installed with
'go install -buildmode=linkshared', but that is a problem
for another day.

Fixes #35759
Updates #34347

Change-Id: Id3e0e068266d5fb9b061a59e70f9a65985d4973b
Reviewed-on: https://go-review.googlesource.com/c/go/+/208233
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
@bcmills
Copy link
Contributor

bcmills commented Nov 22, 2019

@vmarkovtsev, could you try this using a go command built from head? It may be fixed.

If it is not fixed, please provide an exact command line (and, ideally, redacted source code) that reproduces the problem.

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 22, 2019
gopherbot pushed a commit that referenced this issue Nov 22, 2019
…ng sys.BuildModeSupported

Updates #34347

Change-Id: I6ea02d4737999bf24f5335508b5ed2352b498122
Reviewed-on: https://go-review.googlesource.com/c/go/+/208458
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
@ianlancetaylor ianlancetaylor removed this from the Go1.14 milestone Dec 5, 2019
@ianlancetaylor ianlancetaylor added this to the Backlog milestone Dec 5, 2019
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@smasher164 smasher164 reopened this Dec 25, 2019
@smasher164 smasher164 removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 25, 2019
@smasher164 smasher164 reopened this Dec 25, 2019
@jayconrod
Copy link
Contributor

The panic was fixed, so at this point, I don't think this issue covers anything outside of #18671. Let's keep this closed as a duplicate.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

8 participants