-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/cmd/gopls: data race on (*Server).client #30091
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
Change https://golang.org/cl/161220 mentions this issue: |
This change fixes a nil error, in addition to cleaning up a spacing error and a typo. It also fixes the golint errors in internal/lsp/cmd. Updates golang/go#30091 Change-Id: I24867bb878fda4e341f87d31bbec701a3814a341 Reviewed-on: https://go-review.googlesource.com/c/161220 Reviewed-by: Ian Cottrell <[email protected]> Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
I just had another go and the race is still present after 40960b6. I think I understand the race and the nil pointer dereference.
The problem AIUI is that (2) can happen before (1), currently. The reason is that Solving this looks a little tricky. It seems designed with interfaces in such a way that it is difficult to construct the client and server simultaneously and have them know about each other before beginning to handle messages. One potential approach that comes to mind would be to build something out of channels, so that |
Thanks for the report and for diagnosing the issue! Adding @ianthehat on this for a decision. |
Ping @ianthehat. I've upgraded gopls recently for the memory improvements in #30309, but now this is not just a race but regularly crashing the server. I am using the Here is a stack trace captured from current gotools master.
|
@pwaller: does gopls consistently crash for you if you don't compile with |
Using |
Change https://golang.org/cl/169999 mentions this issue: |
Change https://golang.org/cl/170003 mentions this issue: |
With this change (finally, after a lot of detours) if you run the lsp tests with `-race -pipe` then you can reliably reproduce the race in golang/go#30091 Change-Id: Ibd9fda5e07409a15d1bc8d14cb46fde41155aa6e Reviewed-on: https://go-review.googlesource.com/c/tools/+/169999 Run-TryBot: Ian Cottrell <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
This changes the basic API of a jsonrpc2 connection to run the read loop as a method rather than in a go routine launched in the NewConn. This allows the handler to be created and bound between construction and the read loop starting, which fixes the race. Fixes golang/go#30091 Change-Id: I8201175affe431819cf473e5194d70c019f58425 Reviewed-on: https://go-review.googlesource.com/c/tools/+/170003 Run-TryBot: Ian Cottrell <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
This changes the basic API of a jsonrpc2 connection to run the read loop as a method rather than in a go routine launched in the NewConn. This allows the handler to be created and bound between construction and the read loop starting, which fixes the race. Fixes golang/go#30091 Change-Id: I8201175affe431819cf473e5194d70c019f58425 Reviewed-on: https://go-review.googlesource.com/c/tools/+/170003 Run-TryBot: Ian Cottrell <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, I am testing on 7f7074d (master at time of writing) with the recent patch for URI escaping applied.
git fetch https://go.googlesource.com/tools refs/changes/77/161077/2 && git cherry-pick FETCH_HEAD
What did you do?
Compile
gopls
with-race
. Usecmd/gopls/forward
. Use vscode-go. I am working out of my$GOPATH
using modules, and haveGO111MODULE=on
.I then did some development using vscode and observed the crash. Afraid I don't have a precise sequence to reproduce, but I wasn't doing anything fancy beyond just using the editor to edit code and perhaps jump to definition.
What did you expect to see?
Things working as normal.
What did you see instead?
The race detector reports warnings and then some time later I also encounter a panic with a nil pointer dereference. I'm including the nil dereference since these may be related?
Nil pointer dereference panic:
Data race warnings:
/cc @stamblerre
The text was updated successfully, but these errors were encountered: