mirror of https://github.com/golang/go.git
internal/lsp: fix race condition caused by config in `go mod tidy`
Reusing the config causes a race condition because it may be modified. Get a new config in the bound function instead. See the logs here: https://storage.googleapis.com/go-build-log/23cc16cd/linux-amd64-race_343e911a.log. Change-Id: Iaab43631740e43ba97cd70f7cd8a3bbaa91c26c9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/257206 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
34b80a0a46
commit
4c77dbd9e5
|
|
@ -106,6 +106,9 @@ func (s *snapshot) ModTidy(ctx context.Context, fh source.FileHandle) (*source.T
|
|||
err: err,
|
||||
}
|
||||
}
|
||||
// Get a new config to avoid races, since it may be modified by
|
||||
// goCommandInvocation.
|
||||
cfg := s.configWithDir(ctx, filepath.Dir(fh.URI().Filename()))
|
||||
tmpURI, runner, inv, cleanup, err := snapshot.goCommandInvocation(ctx, cfg, true, "mod", []string{"tidy"})
|
||||
if err != nil {
|
||||
return &modTidyData{err: err}
|
||||
|
|
|
|||
Loading…
Reference in New Issue