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: panic in mod tidy when requiring main module #46078

Closed
seankhliao opened this issue May 10, 2021 · 2 comments
Closed

cmd/go: panic in mod tidy when requiring main module #46078

seankhliao opened this issue May 10, 2021 · 2 comments
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@seankhliao
Copy link
Member

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

$ go version
go version devel go1.17-c14ecac Sun May 9 17:07:22 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

1.16.4 has a different error

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/arccy/.cache/go-build"
GOENV="/home/arccy/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/arccy/.data/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/arccy/.data/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/arccy/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/arccy/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.17-c14ecac Sun May 9 17:07:22 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/arccy/tmp/testrepo-425/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-build3574983894=/tmp/go-build -gno-record-gcc-switches"

What did you do?

add a require for the main module, run go mod tidy

main » cat go.mod
module go.seankhliao.com/testrepo-425

go 1.17

require go.seankhliao.com/testrepo-425 v0.0.0

main » cat main.go
package main

func main() {}

main » go version
go version devel go1.17-c14ecac Sun May 9 17:07:22 2021 +0000 linux/amd64

main » go mod tidy
panic: newRequirements called with untrimmed build list: rootModules[0] is Target

goroutine 1 [running]:
cmd/go/internal/modload.newRequirements(0x0, {0xc00013c380, 0x1, 0x1}, 0xc0001a1fb0)
	/home/arccy/sdk/gotip/src/cmd/go/internal/modload/buildlist.go:103 +0x5f9
cmd/go/internal/modload.updateLazyRoots({0xa688a0, 0xc00011a000}, 0xc0001a1fb0, 0xc00012c230, {0x0, 0x0, 0x6}, {0x0, 0x0, 0x0})
	/home/arccy/sdk/gotip/src/cmd/go/internal/modload/buildlist.go:780 +0x5ed
cmd/go/internal/modload.updateRoots({0xa688a0, 0xc00011a000}, 0x203000, 0x203000, {0x0, 0xc0001a1f80, 0xc0001c2d00}, {0x0, 0x0, 0x0})
	/home/arccy/sdk/gotip/src/cmd/go/internal/modload/buildlist.go:524 +0x71
cmd/go/internal/modload.requirementsFromModFile({0xa688a0, 0xc00011a000})
	/home/arccy/sdk/gotip/src/cmd/go/internal/modload/init.go:696 +0x5d2
cmd/go/internal/modload.loadModFile({0xa688a0, 0xc00011a000})
	/home/arccy/sdk/gotip/src/cmd/go/internal/modload/init.go:440 +0x3ff
cmd/go/internal/modload.LoadPackages({0xa688a0, 0xc00011a000}, {{0x0, 0x0}, 0xc0001a1cb0, 0x1, 0x1, 0x1, 0x0, 0x1, ...}, ...)
	/home/arccy/sdk/gotip/src/cmd/go/internal/modload/load.go:315 +0x230
cmd/go/internal/modcmd.runTidy({0xa688a0, 0xc00011a000}, 0xc000146270, {0xc000114170, 0x0, 0x7ffea9940cbe})
	/home/arccy/sdk/gotip/src/cmd/go/internal/modcmd/tidy.go:82 +0x1c9
main.main()
	/home/arccy/sdk/gotip/src/cmd/go/main.go:201 +0xadf

main » go1.16.4 mod tidy
go: go.seankhliao.com/testrepo-425@v0.0.0: reading go.seankhliao.com/testrepo-425/go.mod at revision v0.0.0: unknown revision v0.0.0

What did you expect to see?

a pretty error message

What did you see instead?

panic

other

cc @bcmills @jayconrod @matloob

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go modules labels May 10, 2021
@jayconrod jayconrod added this to the Go1.17 milestone May 10, 2021
@cuonglm
Copy link
Member

cuonglm commented May 10, 2021

git bisect point to 9a81702

@bcmills bcmills self-assigned this May 10, 2021
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/319009 mentions this issue: cmd/go/internal/modload: in updateLazyLoots, do not require the main module explicitly

@golang golang locked and limited conversation to collaborators May 12, 2022
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants