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: 1.11rc1 panic when running "go mod tidy" in an empty module #27066

Closed
apparentlymart opened this issue Aug 18, 2018 · 2 comments
Closed

Comments

@apparentlymart
Copy link

Please answer these questions before submitting your issue. Thanks!

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

go version go1.11rc1 linux/amd64

Does this issue reproduce with the latest release?

Yes, 1.11rc1 is the latest release at the time of writing.

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mart/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mart/go"
GOPROXY=""
GORACE=""
GOROOT="/home/mart/apps/go-1.11-rc1"
GOTMPDIR=""
GOTOOLDIR="/home/mart/apps/go-1.11-rc1/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/mart/Devel/experiment/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-build536392136=/tmp/go-build -gno-record-gcc-switches"

What did you do?

In a new directory, I created a go.mod file with the following content:

module github.com/apparentlymart/experiment

No other file or directory is present in this directory.

I then ran go mod tidy.

What did you expect to see?

I expected this to be a no-op, returning to my shell prompt with no error.

(I ran this mainly out of curiosity, not because I expected any particular result.)

What did you see instead?

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
cmd/go/internal/modload.(*mvsReqs).required(0xc0000f4460, 0xc000118960, 0x23, 0x0, 0x0, 0xc00012d4f8, 0x40f639, 0x8e8b40, 0xc0000a8ea8, 0xc00012d598)
	/usr/local/go/src/cmd/go/internal/modload/load.go:835 +0x1232
cmd/go/internal/modload.(*mvsReqs).Required.func1(0xc0000bc504, 0x913fe0)
	/usr/local/go/src/cmd/go/internal/modload/load.go:765 +0x83
cmd/go/internal/par.(*Cache).Do(0xc0000f4478, 0x913fe0, 0xc0000bc4e0, 0xc00012d708, 0xc00012d8d0, 0xc00012d810)
	/usr/local/go/src/cmd/go/internal/par/work.go:128 +0xd6
cmd/go/internal/modload.(*mvsReqs).Required(0xc0000f4460, 0xc000118960, 0x23, 0x0, 0x0, 0xc0000f4460, 0x70, 0x68, 0x925c60, 0x0)
	/usr/local/go/src/cmd/go/internal/modload/load.go:764 +0x10f
cmd/go/internal/modcmd.modTidyGoSum.func1(0xc000118960, 0x23, 0x0, 0x0)
	/usr/local/go/src/cmd/go/internal/modcmd/tidy.go:80 +0x10b
cmd/go/internal/modcmd.modTidyGoSum()
	/usr/local/go/src/cmd/go/internal/modcmd/tidy.go:87 +0x164
cmd/go/internal/modcmd.runTidy(0xd56020, 0xc0000a6080, 0x0, 0x0)
	/usr/local/go/src/cmd/go/internal/modcmd/tidy.go:66 +0x513
main.main()
	/usr/local/go/src/cmd/go/main.go:218 +0x7d4

It seems that this line is expecting at least one element in r.buildList:

func (r *mvsReqs) required(mod module.Version) ([]module.Version, error) {
if mod == Target {
if modFile.Go != nil {
r.versions.LoadOrStore(mod, modFile.Go.Version)
}
var list []module.Version
return append(list, r.buildList[1:]...), nil
}

@apparentlymart apparentlymart changed the title cmd/go: panic when running "go mod tidy" in an empty module cmd/go: 1.11rc1 panic when running "go mod tidy" in an empty module Aug 18, 2018
@agnivade
Copy link
Contributor

Duplicate of #26808

@agnivade agnivade marked this as a duplicate of #26808 Aug 18, 2018
@gopherbot
Copy link

Change https://golang.org/cl/129799 mentions this issue: cmd/go: fix go mod tidy crash on empty module

gopherbot pushed a commit that referenced this issue Aug 18, 2018
Fixes #27066.

Change-Id: Iede4385ad86b42d7d90814965b161a7e64d29833
Reviewed-on: https://go-review.googlesource.com/129799
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Aug 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants