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: go run golang.org/x/example@<version> panics when run in a workspace #51390

Closed
findleyr opened this issue Feb 28, 2022 · 8 comments
Closed
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@findleyr
Copy link
Contributor

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

$ go version
go version devel go1.18-a064a4f29a Sat Feb 26 01:16:03 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

No.

What did you do?

  1. Patch https://go.dev/cl/388274
  2. cd typeparams/example
  3. go run golang.org/x/example/gotypes@master generic-go-types.md

What did you expect to see?

Successful execution.

What did you see instead?

> go run golang.org/x/example/gotypes@master generic-go-types.md
panic: golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d is not reachable from any root

goroutine 27 [running]:
cmd/go/internal/mvs.(*Graph).Require(0xc00030c940, {{0x7ffe19407be3?, 0xc0006bc0f0?}, {0xc0006bc0f0?, 0xc0000f0f60?}}, {0xc00007ae80, 0x1, 0xc0006f1de0?})
        /home/rfindley/src/go/src/cmd/go/internal/mvs/graph.go:62 +0x41e
cmd/go/internal/modload.readModGraph.func2.1()
        /home/rfindley/src/go/src/cmd/go/internal/modload/buildlist.go:334 +0x105
cmd/go/internal/par.(*Cache).Do(0xc0000ad688, {0x987f40, 0xc00007ad20}, 0xc00006deb0)
        /home/rfindley/src/go/src/cmd/go/internal/par/work.go:128 +0xc3
cmd/go/internal/modload.readModGraph.func2({{0x7ffe19407be3?, 0x1?}, {0xc0006bc0f0?, 0xf1?}})
        /home/rfindley/src/go/src/cmd/go/internal/modload/buildlist.go:329 +0x132
cmd/go/internal/modload.readModGraph.func3.1()
        /home/rfindley/src/go/src/cmd/go/internal/modload/buildlist.go:362 +0x44
cmd/go/internal/par.(*Queue).Add.func1()
        /home/rfindley/src/go/src/cmd/go/internal/par/queue.go:58 +0x7d
created by cmd/go/internal/par.(*Queue).Add
        /home/rfindley/src/go/src/cmd/go/internal/par/queue.go:56 +0x225

This command succeeds using go1.17.1, but panics at tip. Maybe I'm unaware of some change in semantics, but since I get a panic I suspect this is a bug.

CC @bcmills @matloob

@findleyr findleyr added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 28, 2022
@findleyr findleyr added this to the Go1.18 milestone Feb 28, 2022
@bcmills bcmills self-assigned this Feb 28, 2022
@bcmills
Copy link
Member

bcmills commented Mar 2, 2022

@findleyr, I'm not able to reproduce this. Could you include the output of go env?

(I wonder if this is a bad interaction between go run …@version and workspace mode; CC @matloob.)

~/src/golang.org/x/exp/typeparams/example$ git status
On branch issue51390-not-reachable
nothing to commit, working tree clean

~/src/golang.org/x/exp/typeparams/example$ git rev-parse HEAD
53806b9de4a2710e6b0c79ee0e95197fbca15912

~/src/golang.org/x/exp/typeparams/example$ go version
go version devel go1.18-a064a4f29a Sat Feb 26 01:16:03 2022 +0000 linux/amd64

~/src/golang.org/x/exp/typeparams/example$ go run golang.org/x/example/gotypes@master generic-go-types.md | wc -l
884

(That is: gotypes generated copious output to stdout. 😅)

@bcmills
Copy link
Member

bcmills commented Mar 2, 2022

Indeed, reproduced by adding a go.work file at the root of x/exp:

~/src/golang.org/x/exp/typeparams/example$ cat ../../go.work
go 1.18

use (
        typeparams
)

~/src/golang.org/x/exp/typeparams/example$ go run golang.org/x/example/gotypes@787a929d5a0d generic-go-types.md | wc -l
panic: golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d is not reachable from any root

goroutine 74 [running]:
cmd/go/internal/mvs.(*Graph).Require(0xc0001b4b40, {{0x7ffe1b39022c?, 0xc000290060?}, {0xc000290060?, 0xc0000e8b70?}}, {0xc0000788c0, 0x1, 0xc000243de0?})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/mvs/graph.go:62 +0x41e
cmd/go/internal/modload.readModGraph.func2.1()
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/buildlist.go:334 +0x105
cmd/go/internal/par.(*Cache).Do(0xc000336368, {0x987f40, 0xc000078760}, 0xc0002f8eb0)
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/par/work.go:128 +0xc3
cmd/go/internal/modload.readModGraph.func2({{0x7ffe1b39022c?, 0x0?}, {0xc000290060?, 0x100?}})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/buildlist.go:329 +0x132
cmd/go/internal/modload.readModGraph.func3.1()
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/buildlist.go:362 +0x44
cmd/go/internal/par.(*Queue).Add.func1()
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/par/queue.go:58 +0x7d
created by cmd/go/internal/par.(*Queue).Add
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/par/queue.go:56 +0x225

goroutine 1 [chan receive]:
cmd/go/internal/modload.readModGraph({0x9346e0?, 0x50?}, 0x2, {0xc000078720?, 0x1, 0x1})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/buildlist.go:387 +0x354
cmd/go/internal/modload.(*Requirements).Graph.func1()
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/buildlist.go:242 +0x3e
sync.(*Once).doSlow(0x4?, 0x0?)
        /usr/local/google/home/bcmills/go/src/sync/once.go:68 +0xc2
sync.(*Once).Do(...)
        /usr/local/google/home/bcmills/go/src/sync/once.go:59
cmd/go/internal/modload.(*Requirements).Graph(0xc00007c7d0?, {0xadb5e0?, 0xc0000240f8?})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/buildlist.go:241 +0x74
cmd/go/internal/modload.expandGraph({0xadb5e0, 0xc0000240f8}, 0xc00007c7d0)
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/buildlist.go:559 +0x45
cmd/go/internal/modload.raiseLimitsForUpgrades({0xadb5e0, 0xc0000240f8}, 0xc0000e8a20?, 0x2, {0x0?, 0x0?, 0x200?}, {0xc000145b90, 0x1, 0x1})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/edit.go:317 +0x2fe
cmd/go/internal/modload.limiterForEdit({0xadb5e0, 0xc0000240f8}, 0xc00007c780, {0x0, 0x0, 0x0}, {0xc000145b90, 0x1, 0x1})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/edit.go:180 +0x17d
cmd/go/internal/modload.editRequirements({0xadb5e0, 0xc0000240f8}, 0xc00007c780, {0x0, 0x0, 0x0}, {0xc000145b90, 0x1, 0xc000145938?})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/edit.go:40 +0x6e
cmd/go/internal/modload.EditBuildList({0xadb5e0, 0xc0000240f8}, {0x0, 0x0, 0x0}, {0xc000145b90, 0x1, 0x1})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/buildlist.go:604 +0x87
cmd/go/internal/load.PackagesAndErrorsOutsideModule({0xadb5e0, 0xc0000240f8}, {0x22?, 0xa0?, 0x9d?}, {0xc0000200a0, 0x1, 0x40ecc5?})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/load/pkg.go:3064 +0x330
cmd/go/internal/run.runRun({0xadb5e0, 0xc0000240f8}, 0xc000028360?, {0xc0000200a0?, 0x2, 0x2})
        /usr/local/google/home/bcmills/go/src/cmd/go/internal/run/run.go:114 +0x310
main.invoke(0xdb9da0, {0xc000020090, 0x3, 0x3})
        /usr/local/google/home/bcmills/go/src/cmd/go/main.go:218 +0x2ee
main.main()
        /usr/local/google/home/bcmills/go/src/cmd/go/main.go:175 +0x78e

goroutine 117 [IO wait]:
internal/poll.runtime_pollWait(0x7fc43ca27658, 0x72)
        /usr/local/google/home/bcmills/go/src/runtime/netpoll.go:302 +0x89
internal/poll.(*pollDesc).wait(0xc0002be180?, 0xc000340000?, 0x0)
        /usr/local/google/home/bcmills/go/src/internal/poll/fd_poll_runtime.go:83 +0x32
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/google/home/bcmills/go/src/internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Read(0xc0002be180, {0xc000340000, 0x2999, 0x2999})
        /usr/local/google/home/bcmills/go/src/internal/poll/fd_unix.go:167 +0x25a
net.(*netFD).Read(0xc0002be180, {0xc000340000?, 0xc000292f60?, 0xc000340005?})
        /usr/local/google/home/bcmills/go/src/net/fd_posix.go:55 +0x29
net.(*conn).Read(0xc000306000, {0xc000340000?, 0x7fc43f3e0d00?, 0x7fc43f3e0c00?})
        /usr/local/google/home/bcmills/go/src/net/net.go:183 +0x45
crypto/tls.(*atLeastReader).Read(0xc000464168, {0xc000340000?, 0x0?, 0x1?})
        /usr/local/google/home/bcmills/go/src/crypto/tls/conn.go:784 +0x3d
bytes.(*Buffer).ReadFrom(0xc00030a278, {0xad6a40, 0xc000464168})
        /usr/local/google/home/bcmills/go/src/bytes/buffer.go:204 +0x98
crypto/tls.(*Conn).readFromUntil(0xc00030a000, {0xad6fa0?, 0xc000306000}, 0x2999?)
        /usr/local/google/home/bcmills/go/src/crypto/tls/conn.go:806 +0xe5
crypto/tls.(*Conn).readRecordOrCCS(0xc00030a000, 0x0)
        /usr/local/google/home/bcmills/go/src/crypto/tls/conn.go:613 +0x116
crypto/tls.(*Conn).readRecord(...)
        /usr/local/google/home/bcmills/go/src/crypto/tls/conn.go:581
crypto/tls.(*Conn).Read(0xc00030a000, {0xc0004c3000, 0x1000, 0x706700?})
        /usr/local/google/home/bcmills/go/src/crypto/tls/conn.go:1284 +0x16f
bufio.(*Reader).Read(0xc000337d40, {0xc0004b8120, 0x9, 0x714b02?})
        /usr/local/google/home/bcmills/go/src/bufio/bufio.go:236 +0x1b4
io.ReadAtLeast({0xad6260, 0xc000337d40}, {0xc0004b8120, 0x9, 0x9}, 0x9)
        /usr/local/google/home/bcmills/go/src/io/io.go:331 +0x9a
io.ReadFull(...)
        /usr/local/google/home/bcmills/go/src/io/io.go:350
net/http.http2readFrameHeader({0xc0004b8120?, 0x9?, 0xc0005001e0?}, {0xad6260?, 0xc000337d40?})
        /usr/local/google/home/bcmills/go/src/net/http/h2_bundle.go:1566 +0x6e
net/http.(*http2Framer).ReadFrame(0xc0004b80e0)
        /usr/local/google/home/bcmills/go/src/net/http/h2_bundle.go:1830 +0x95
net/http.(*http2clientConnReadLoop).run(0xc000111f98)
        /usr/local/google/home/bcmills/go/src/net/http/h2_bundle.go:8815 +0x130
net/http.(*http2ClientConn).readLoop(0xc000308480)
        /usr/local/google/home/bcmills/go/src/net/http/h2_bundle.go:8711 +0x6f
created by net/http.(*http2Transport).newClientConn
        /usr/local/google/home/bcmills/go/src/net/http/h2_bundle.go:7439 +0xa65
0

@bcmills
Copy link
Member

bcmills commented Mar 2, 2022

The fix, I think, is to make go run pkg@version ignore the go.work file.

@bcmills bcmills added modules NeedsFix The path to resolution is known, but the work has not been done. labels Mar 2, 2022
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 2, 2022
@findleyr
Copy link
Contributor Author

findleyr commented Mar 2, 2022

@findleyr, I'm not able to reproduce this. Could you include the output of go env?

Oof, apologies! I would have reported that I had a go.work file, but I forgot! (I have a global .gitignore for go.work -- still getting used to it).

@gopherbot
Copy link

Change https://go.dev/cl/388917 mentions this issue: cmd/go: ignore the workspace when running a package at a specified version

@gopherbot
Copy link

Change https://go.dev/cl/389575 mentions this issue: [release-branch.go1.18] cmd/go: ignore the workspace when running a package at a specified version

@bcmills
Copy link
Member

bcmills commented Mar 3, 2022

This is merged at tip, and can be fixed by merging the 1.18 backport whenever it has a +2 and passing TryBot run.

gopherbot pushed a commit that referenced this issue Mar 3, 2022
…rsion

For #51390

Change-Id: I805e66809b2aafb48f7040dee72910dd7d6c1396
Reviewed-on: https://go-review.googlesource.com/c/go/+/388917
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
@bcmills bcmills changed the title cmd/go: panic: golang.org/x/example@<version> is not reachable from any root cmd/go: go run golang.org/x/example@<version> panics when run in a workspace Mar 3, 2022
gopherbot pushed a commit that referenced this issue Mar 7, 2022
…ackage at a specified version

Fixes #51390

Change-Id: I805e66809b2aafb48f7040dee72910dd7d6c1396
Reviewed-on: https://go-review.googlesource.com/c/go/+/388917
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit 86b5f6a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/389575
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
@dmitshur
Copy link
Contributor

dmitshur commented Mar 7, 2022

Closed by merging 9f40b4f to release-branch.go1.18.

@dmitshur dmitshur closed this as completed Mar 7, 2022
@rsc rsc unassigned bcmills and matloob Jun 22, 2022
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants