]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/modload: break more cycles in readModGraph
authorBryan C. Mills <bcmills@google.com>
Tue, 30 May 2023 14:35:54 +0000 (10:35 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 30 May 2023 16:18:15 +0000 (16:18 +0000)
commit58e42b946bbfda3ff98292aa6205fae7882fd5dc
tree26a8b3ce51569936625ffabba5b909b3c80f1f62
parentbfa25c3f6c72829cd36f5701418f726702de9c06
cmd/go/internal/modload: break more cycles in readModGraph

Before CL 471595, modload.readModGraph in module with graph pruning
enabled only ever chased down transitive dependencies of unpruned
roots, so pruned dependencies couldn't cause cycles and we didn't
need to dedup them in the loading queue.

However, in 'go get' we are now passing in a set of upgraded modules
to unprune, and those upgraded modules can potentially contain cycles,
leading to an infinite loop during loading.

We have two options for a fix: we could either drop the 'unprune'
check in the enqueue operation (and instead expand the 'unprune'
requirements in a separate pass, as we do in workspace mode), or we
could check for cycles for all modules (not just the ones that are
naturally unpruned). The latter option makes it clearer that this
process must terminate, so we choose that.

(It may be possible to clean up and simplify the workspace-mode case
now that we are passing in the 'unprune' map, but for now we're
looking for a minimal fix for the Go 1.21 release.)

Fixes #60490.

Change-Id: I701f5d43a35e357f6c0c0c9d10b7aa088f917311
Reviewed-on: https://go-review.googlesource.com/c/go/+/499195
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
src/cmd/go/internal/modload/buildlist.go
src/cmd/go/testdata/script/mod_get_issue60490.txt [new file with mode: 0644]