Skip to content

Commit d2b436d

Browse files
author
Jay Conrod
committed
cmd/go: fix infinite loop in modload.keepSums
Fixes #42891 Change-Id: I0cce4204a1c4959b896188a2ab3719c0507f95e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/274172 Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Matloob <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Trust: Jay Conrod <[email protected]>
1 parent 4f42a9b commit d2b436d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/cmd/go/internal/modload/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ func keepSums(addDirect bool) map[module.Version]bool {
10181018
}
10191019
}
10201020
for _, pkg := range loaded.pkgs {
1021-
if pkg.testOf != nil || pkg.inStd {
1021+
if pkg.testOf != nil || pkg.inStd || module.CheckImportPath(pkg.path) != nil {
10221022
continue
10231023
}
10241024
for prefix := pkg.path; prefix != "."; prefix = path.Dir(prefix) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# If an import declaration is an absolute path, most commands should report
2+
# an error instead of going into an infinite loop.
3+
# Verifies golang.org/issue/42891.
4+
go list .
5+
stdout '^m$'
6+
7+
-- go.mod --
8+
module m
9+
10+
go 1.16
11+
-- m.go --
12+
package m
13+
14+
import "/"

0 commit comments

Comments
 (0)