Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/cmd/gopls: data race on (*Server).client #30091
What version of Go are you using (
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@example.com> Run-TryBot: Rebecca Stambler <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com>
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
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.
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 <firstname.lastname@example.org> Reviewed-by: Rebecca Stambler <email@example.com>
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 <firstname.lastname@example.org> Reviewed-by: Rebecca Stambler <email@example.com>