-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/vet, go/types: go vet
crash when using self-recursive anonymous types in constraints
#51717
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
Comments
go vet
crash when using anonymous types in constraints
go vet
crash when using anonymous types in constraintsgo vet
crash when using self-recursive anonymous types in constraints
Thank you for the report. Investigating now. |
This is a bug in the x/tools/go/types/objectpath package: it needs to cycle-break on type-parameters when searching for objects. |
Change https://go.dev/cl/393376 mentions this issue: |
@gopherbot please backport this to 1.18, it is an infinite recursion when running cmd/vet on valid code. |
Backport issue(s) opened: #51727 (for 1.18). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
When searching for objects, we naively traversed through type parameter constraints. This leads to infinite recursion when there are cycles through type parameter constraints. Break these cycles by tracking type parameter names that have previously been encountered. This ensures we walk type parameter constraints at most once. Note that if the desired object was not found on the first search of the constraint, there is no need to search again. For golang/go#51717 Change-Id: Ifcdf4b138a0e95441e485bbb9ee21c01b04eaed4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/393376 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Change https://go.dev/cl/393373 mentions this issue: |
Change https://go.dev/cl/393635 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, with
go1.18 linux/amd64
.What did you do?
Running
go vet
on the following legal Go 1.18 code causes a stack overflow:https://gotipplay.golang.org/p/XWvgmRsOFpy
Additional notes:
panic("")
call is removed, or when it is replaced with a call to a locally declared function (e.g.func G() {}
orfunc G(_ string) {}
).go/types
only used bygo vet
, but not bygo compile
.What did you expect to see?
A successful execution of
go vet
.What did you see instead?
A stack overflow error related to
go/types.computeInterfaceTypeSet
:The text was updated successfully, but these errors were encountered: