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
x/tools/gopls: crash upon creating empty linked list #45510
Comments
I am unable to get any indication that gopls has crashed with the given examples. Does not crash with:
Still does not crash with a invalid file containing exactly:
|
It is not a gopls bug then. I am testing on vscode and this exact same program causes vscode to hang while "Getting actions from 'Go'" |
I too am running vscode and got no such thing. However what you are describing sounds a lot like vscode is still starting up, when you do a fresh launch of vscode it is known to sometimes take a while to startup all the plugins and related tools so if you do a edit and save too quickly then it has to wait for all of that to finish loading. Try waiting a few minutes after oppening vscode and see if it still hangs. |
@soypat: Can you please share your Go version? This type of bug may have been fixed with later versions of Go. |
I could reproduce this behavior: package main
type a *a
var x a = <> // try to complete
func main() {}
func Deref(typ types.Type) types.Type {
for {
p, ok := typ.Underlying().(*types.Pointer)
if !ok {
return typ
}
// log.Printf("current typ: %#v\n", typ)
// log.Printf("new typ (pointer elem): %#v\n", p.Elem())
typ = p.Elem()
}
}
So, this loop is infinite. Stack trace
|
Ok I can reproduce this now but the steps to reproduce wasn't clear. First create a file and fill it with and save:
Next edit this line and save again: |
Sorry. I'll make sure steps are clearer next time. Did not think saving the file was crucial part of steps |
Thanks for figuring out the cause of this bug, @ShoshinNikita! Do you want to send the CL to fix it or would you rather a member of the |
I would be happy to send a CL but I am not sure about the fix. Should we just return the current |
Yeah I think that would work. |
Return a pointer type if the type refers to itself (for example, type a *a). Fixes golang/go#45510
Change https://golang.org/cl/310050 mentions this issue: |
I don't think this fix is sufficient for cyclic types like:
|
Yeah, the current fix doesn't work for such cyclic types. I think we can use |
One slight optimization is that you only have to worry about named pointer types (i.e. you only have to allocate/insert into your map when you see a named pointer type). |
The previous fix (d1362d7) is not sufficient for all cyclic types. This change updates Deref function to support more complex cases. We use a map with underlying types to detect cycles. Fixes golang/go#45510
Change https://golang.org/cl/310311 mentions this issue: |
The previous fix (d1362d7) is not sufficient for all cyclic types. This change updates Deref function to support more complex cases. We use a map with underlying types to detect cycles. Fixes golang/go#45510 Change-Id: I28f655a9c1d4f363cb7ae3f47db3e8567fe6e80a GitHub-Last-Rev: 4c89874 GitHub-Pull-Request: #305 Reviewed-on: https://go-review.googlesource.com/c/tools/+/310311 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Trust: Rebecca Stambler <rstambler@golang.org> Trust: Robert Findley <rfindley@google.com> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org>
Here's a hard one for you.
What version of Gopls are you using ?
What did you do?
Create new program from scratch, write:
or
What did you expect to see?
gopls ask me why I would want to use this crazy datastructure
What did you see instead?
gopls crashes
The text was updated successfully, but these errors were encountered: