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 when running "go mod vendor" on tip #46659

Closed
kevinburke1 opened this issue Jun 9, 2021 · 10 comments
Closed

cmd/go: panic when running "go mod vendor" on tip #46659

kevinburke1 opened this issue Jun 9, 2021 · 10 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.
Milestone

Comments

@kevinburke1
Copy link

kevinburke1 commented Jun 9, 2021

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

$ go version
go version devel go1.17-6551763a60 Tue Jun 8 20:45:46 2021 +0000 darwin/amd64

Does this issue reproduce with the latest release?

No

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

go env Output
$ go env
GO111MODULE="off"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kevin/Library/Caches/go-build"
GOENV="/Users/kevin/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kevin/pkg/mod"
GONOPROXY="github.com/meterup"
GONOSUMDB="github.com/meterup"
GOOS="darwin"
GOPATH="/Users/kevin"
GOPRIVATE="github.com/meterup"
GOPROXY="direct"
GOROOT="/Users/kevin/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/kevin/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.17-6551763a60 Tue Jun 8 20:45:46 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/s1/909yt58s4wj8h_7v7frr8rkm0000gn/T/go-build73385364=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version devel go1.17-6551763a60 Tue Jun 8 20:45:46 2021 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel go1.17-6551763a60 Tue Jun 8 20:45:46 2021 +0000
uname -v: Darwin Kernel Version 19.6.0: Thu May  6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H1217
lldb --version: lldb-1200.0.44.2
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
gdb --version: GNU gdb (GDB) 10.2

What did you do?

Added the following to go.mod and ran "go mod vendor && go mod tidy"

module github.com/meterup/packages/go/terraform

go 1.16

require github.com/hashicorp/terraform v0.15.5

// These "replace" directives are from Terraform 0.15.3 - Terraform 0.15.5 has different replace directives

replace google.golang.org/grpc v1.31.1 => google.golang.org/grpc v1.27.1

replace k8s.io/client-go => k8s.io/client-go v0.0.0-20190620085101-78d2af792bab

What did you expect to see?

All of the packages placed in the vendor directory

What did you see instead?

go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
panic: internal error: adding [google.golang.org/grpc@v1.31.1] to module graph had no effect on root requirements ([github.com/hashicorp/terraform@v0.15.5])

goroutine 1 [running]:
cmd/go/internal/modload.loadFromRoots({0x166e5c0, 0xc000024130}, {{{0x0, 0x0}, 0xc0001a2060, 0x1, {0x0, 0x0}, 0x1, 0x1, ...}, ...})
	/Users/kevin/go/src/cmd/go/internal/modload/load.go:1090 +0x12e9
cmd/go/internal/modload.LoadPackages({0x166e5c0, 0xc000024130}, {{0x0, 0x0}, 0xc0001a2060, 0x1, {0x0, 0x0}, 0x1, 0x1, ...}, ...)
	/Users/kevin/go/src/cmd/go/internal/modload/load.go:324 +0x328
cmd/go/internal/modcmd.runTidy({0x166e5c0, 0xc000024130}, 0xc0000284c8, {0xc0000201d0, 0x0, 0x7ffeefbff497})
	/Users/kevin/go/src/cmd/go/internal/modcmd/tidy.go:114 +0x1b7
main.main()
	/Users/kevin/go/src/cmd/go/main.go:201 +0xadf
make: *** [Makefile:8: vendor] Error 2
@kevinburke1
Copy link
Author

So I had the dependencies wrong. I was looking at the go.mod (and replace directives) for Terraform v0.15.3 (or possibly earlier) when I ran make vendor. When I updated the replace directives to match Terraform v0.15.5, I was able to run make vendor successfully.

Still, it doesn't seem like Go should be panicking during normal operation.

When I run the command with Go 1.16, I get an infinite loop:

go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1

@seankhliao
Copy link
Member

can you share the contents of go.mod?

@seankhliao seankhliao changed the title panic when running "go mod vendor" on tip cmd/go: panic when running "go mod vendor" on tip Jun 9, 2021
@seankhliao seankhliao added GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 9, 2021
@seankhliao
Copy link
Member

cc @bcmills @jayconrod @matloob

@bcmills bcmills self-assigned this Jun 10, 2021
@bcmills bcmills added this to the Go1.17 milestone Jun 10, 2021
@bcmills
Copy link
Contributor

bcmills commented Jun 10, 2021

(I'm going to try to fix this by the 1.17 final, but since it infinite-loops on 1.16 it's not a release blocker.)

@bcmills
Copy link
Contributor

bcmills commented Jun 10, 2021

@kevinburkemeter, could you give a bit more detail about the relevant replace and require directives before and after you updated them to match Terraform v0.15.5? (If this was in an open-source repo, specific commits would be really helpful so I can distill them into a regression test.)

@kevinburke1
Copy link
Author

Gah, yeah, I'm sorry, I thought I pasted the go.mod file but clearly I didn't. One second.

@kevinburke1
Copy link
Author

I've updated the issue description with the go.mod file that reproduces the panic

@bcmills bcmills modified the milestones: Go1.17, Backlog Jun 24, 2021
@bcmills
Copy link
Contributor

bcmills commented Jun 24, 2021

Thanks. This reproduces easily running go mod tidy at tip with the following contents:

-- go.mod --
module golang.org/issue46659

go 1.16

require github.com/hashicorp/terraform v0.15.5

replace (
	google.golang.org/grpc v1.31.1 => google.golang.org/grpc v1.27.1
	k8s.io/client-go => k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
)
-- tools.go --
//go:build tools

package tools

import (
	_ "github.com/hashicorp/terraform"
)

@bcmills
Copy link
Contributor

bcmills commented Jun 24, 2021

go1.15.13 has yet another different (but still failing) failure mode:

$ go1.15.13 mod tidy
go: downloading github.com/boltdb/bolt v1.3.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: golang.org/issue46659 imports
        github.com/hashicorp/terraform imports
        github.com/hashicorp/terraform/internal/backend/init imports
        github.com/hashicorp/terraform/internal/backend/remote-state/etcdv2 imports
        github.com/coreos/etcd/client tested by
        github.com/coreos/etcd/client.test imports
        github.com/coreos/etcd/integration imports
        github.com/coreos/etcd/proxy/grpcproxy imports
        google.golang.org/grpc/naming: looping trying to add package

@gopherbot
Copy link

Change https://golang.org/cl/330432 mentions this issue: cmd/go: don't try to add replaced versions that won't be selected

@rsc rsc unassigned bcmills Jun 23, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
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.
Projects
None yet
Development

No branches or pull requests

4 participants