Skip to content
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/internal/lsp/source: race detected during execution of TestSource #40080

Closed
dmitshur opened this issue Jul 6, 2020 · 2 comments
Closed
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@dmitshur
Copy link
Contributor

dmitshur commented Jul 6, 2020

Spotted via linux-amd64-race and windows-amd64-race builders at https://build.golang.org/?repo=golang.org%2fx%2ftools:

--- FAIL: TestSource (99.21s)
    --- FAIL: TestSource/GOPATH (56.52s)
        --- FAIL: TestSource/GOPATH/testdata/lsp (47.57s)
            --- FAIL: TestSource/GOPATH/testdata/lsp/RankCompletions (39.71s)
                --- FAIL: TestSource/GOPATH/testdata/lsp/RankCompletions/convert_rank_33_10_2 (0.08s)
                    testing.go:853: race detected during execution of test
                testing.go:853: race detected during execution of test
            testing.go:853: race detected during execution of test
        testing.go:853: race detected during execution of test
    --- FAIL: TestSource/Modules (42.69s)
        --- FAIL: TestSource/Modules/testdata/lsp (37.25s)
            --- FAIL: TestSource/Modules/testdata/lsp/RankCompletions (30.50s)
                --- FAIL: TestSource/Modules/testdata/lsp/RankCompletions/append_14_19_1 (0.33s)
                    testing.go:853: race detected during execution of test
                testing.go:853: race detected during execution of test
            testing.go:853: race detected during execution of test
        testing.go:853: race detected during execution of test
    testing.go:853: race detected during execution of test
FAIL
FAIL	golang.org/x/tools/internal/lsp/source	99.698s
==================
WARNING: DATA RACE
Write at 0x00c0039b0210 by goroutine 1036:
  golang.org/x/tools/internal/lsp/cache.(*View).populateProcessEnv()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/cache/view.go:477 +0x32d
  golang.org/x/tools/internal/lsp/cache.(*View).RunProcessEnvFunc()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/cache/view.go:393 +0x153
  golang.org/x/tools/internal/lsp/source.(*completer).unimportedPackages()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/completion.go:1189 +0xb38
  golang.org/x/tools/internal/lsp/source.(*completer).lexical()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/completion.go:1075 +0x1048
  golang.org/x/tools/internal/lsp/source.Completion()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/completion.go:586 +0x184f
  golang.org/x/tools/internal/lsp/source_test.(*runner).callCompletion()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/source_test.go:244 +0x743
  golang.org/x/tools/internal/lsp/source_test.(*runner).RankCompletion()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/source_test.go:221 +0x35f
  golang.org/x/tools/internal/lsp/tests.Tests.RankCompletion-fm()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/tests/tests.go:126 +0x114
  golang.org/x/tools/internal/lsp/tests.Run.func1.1()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/tests/tests.go:463 +0x245
  testing.tRunner()
      C:/workdir/go/src/testing/testing.go:909 +0x1a0

Previous read at 0x00c0039b0210 by goroutine 1632:
  golang.org/x/tools/internal/imports.(*ProcessEnv).goroot()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/fix.go:781 +0x49
  golang.org/x/tools/internal/imports.(*ProcessEnv).buildContext()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/fix.go:847 +0xd6
  golang.org/x/tools/internal/imports.(*gopathResolver).scan()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/fix.go:1272 +0x243
  golang.org/x/tools/internal/imports.getCandidatePkgs()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/fix.go:643 +0xa93
  golang.org/x/tools/internal/imports.PrimeCache()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/fix.go:667 +0x14a
  golang.org/x/tools/internal/lsp/cache.(*View).refreshProcessEnv()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/cache/view.go:450 +0x1bc
  golang.org/x/tools/internal/lsp/cache.(*View).refreshProcessEnv-fm()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/cache/view.go:440 +0x48

Goroutine 1036 (running) created at:
  testing.(*T).Run()
      C:/workdir/go/src/testing/testing.go:960 +0x658
  golang.org/x/tools/internal/lsp/tests.Run.func1()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/tests/tests.go:455 +0x3cd
  golang.org/x/tools/internal/lsp/tests.Run.func9()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/tests/tests.go:538 +0x11e
  testing.tRunner()
      C:/workdir/go/src/testing/testing.go:909 +0x1a0

Goroutine 1632 (running) created at:
  time.goFunc()
      C:/workdir/go/src/time/sleep.go:168 +0x58
==================
==================
WARNING: DATA RACE
Write at 0x00c0079a87b0 by goroutine 1363:
  golang.org/x/tools/internal/lsp/cache.(*View).populateProcessEnv()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/cache/view.go:477 +0x32d
  golang.org/x/tools/internal/lsp/cache.(*View).RunProcessEnvFunc()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/cache/view.go:393 +0x153
  golang.org/x/tools/internal/lsp/source.(*completer).unimportedPackages()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/completion.go:1124 +0x163a
  golang.org/x/tools/internal/lsp/source.(*completer).lexical()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/completion.go:1075 +0x1048
  golang.org/x/tools/internal/lsp/source.Completion()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/completion.go:586 +0x184f
  golang.org/x/tools/internal/lsp/source_test.(*runner).callCompletion()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/source_test.go:244 +0x743
  golang.org/x/tools/internal/lsp/source_test.(*runner).RankCompletion()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/source/source_test.go:221 +0x35f
  golang.org/x/tools/internal/lsp/tests.Tests.RankCompletion-fm()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/tests/tests.go:126 +0x114
  golang.org/x/tools/internal/lsp/tests.Run.func1.1()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/tests/tests.go:463 +0x245
  testing.tRunner()
      C:/workdir/go/src/testing/testing.go:909 +0x1a0

Previous read at 0x00c0079a87b0 by goroutine 406:
  golang.org/x/tools/internal/imports.(*ProcessEnv).goroot()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/fix.go:781 +0x49
  golang.org/x/tools/internal/imports.(*ProcessEnv).buildContext()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/fix.go:847 +0xd6
  golang.org/x/tools/internal/imports.(*ModuleResolver).findPackage()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/mod.go:243 +0x4cc
  golang.org/x/tools/internal/imports.(*ModuleResolver).canonicalize()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/mod.go:545 +0x408
  golang.org/x/tools/internal/imports.(*ModuleResolver).scan.func1()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/mod.go:403 +0x14e
  golang.org/x/tools/internal/imports.(*dirInfoCache).ScanAndListen.func1()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/mod_cache.go:130 +0x175
  golang.org/x/tools/internal/imports.(*dirInfoCache).Store()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/mod_cache.go:173 +0x474
  golang.org/x/tools/internal/imports.(*ModuleResolver).cacheStore()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/mod.go:262 +0x1c5
  golang.org/x/tools/internal/imports.(*ModuleResolver).scan.func3()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/mod.go:449 +0x11a
  golang.org/x/tools/internal/gopathwalk.(*walker).walk()
      C:/workdir/gopath/src/golang.org/x/tools/internal/gopathwalk/walk.go:200 +0x5cf
  golang.org/x/tools/internal/gopathwalk.(*walker).walk-fm()
      C:/workdir/gopath/src/golang.org/x/tools/internal/gopathwalk/walk.go:188 +0x68
  golang.org/x/tools/internal/fastwalk.(*walker).onDirEnt()
      C:/workdir/gopath/src/golang.org/x/tools/internal/fastwalk/fastwalk.go:168 +0xed
  golang.org/x/tools/internal/fastwalk.(*walker).onDirEnt-fm()
      C:/workdir/gopath/src/golang.org/x/tools/internal/fastwalk/fastwalk.go:161 +0x7f
  golang.org/x/tools/internal/fastwalk.readDir()
      C:/workdir/gopath/src/golang.org/x/tools/internal/fastwalk/fastwalk_portable.go:28 +0x1b8
  golang.org/x/tools/internal/fastwalk.(*walker).walk()
      C:/workdir/gopath/src/golang.org/x/tools/internal/fastwalk/fastwalk.go:195 +0x81
  golang.org/x/tools/internal/fastwalk.(*walker).doWork()
      C:/workdir/gopath/src/golang.org/x/tools/internal/fastwalk/fastwalk.go:134 +0x251

Goroutine 1363 (running) created at:
  testing.(*T).Run()
      C:/workdir/go/src/testing/testing.go:960 +0x658
  golang.org/x/tools/internal/lsp/tests.Run.func1()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/tests/tests.go:455 +0x3cd
  golang.org/x/tools/internal/lsp/tests.Run.func9()
      C:/workdir/gopath/src/golang.org/x/tools/internal/lsp/tests/tests.go:538 +0x11e
  testing.tRunner()
      C:/workdir/go/src/testing/testing.go:909 +0x1a0

Goroutine 406 (finished) created at:
  golang.org/x/tools/internal/fastwalk.Walk()
      C:/workdir/gopath/src/golang.org/x/tools/internal/fastwalk/fastwalk.go:81 +0x360
  golang.org/x/tools/internal/gopathwalk.walkDir()
      C:/workdir/gopath/src/golang.org/x/tools/internal/gopathwalk/walk.go:101 +0x3c3
  golang.org/x/tools/internal/gopathwalk.WalkSkip()
      C:/workdir/gopath/src/golang.org/x/tools/internal/gopathwalk/walk.go:78 +0xc8
  golang.org/x/tools/internal/imports.(*ModuleResolver).scan.func4()
      C:/workdir/gopath/src/golang.org/x/tools/internal/imports/mod.go:474 +0x3cf
==================

/cc @stamblerre per owners.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 6, 2020
@dmitshur dmitshur added this to the Unreleased milestone Jul 6, 2020
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jul 6, 2020
@dmitshur
Copy link
Contributor Author

dmitshur commented Jul 6, 2020

I was able to reproduce locally on darwin/amd64 at golang/tools@95bc2bd with:

$ go version
go version go1.14.4 darwin/amd64
$ go test -count=10 -race golang.org/x/tools/internal/lsp/source
[...]
--- FAIL: TestSource (136.45s)
    --- FAIL: TestSource/Modules (85.73s)
        --- FAIL: TestSource/Modules/testdata/lsp (80.09s)
            --- FAIL: TestSource/Modules/testdata/lsp/RankCompletions (71.05s)
                --- FAIL: TestSource/Modules/testdata/lsp/RankCompletions/multi_return_16_11_1 (0.81s)
                    testing.go:906: race detected during execution of test
                testing.go:906: race detected during execution of test
            testing.go:906: race detected during execution of test
        testing.go:906: race detected during execution of test
    testing.go:906: race detected during execution of test
[...]
FAIL	golang.org/x/tools/internal/lsp/source	600.905s
FAIL

@stamblerre
Copy link
Contributor

Duplicate of #39865

@stamblerre stamblerre marked this as a duplicate of #39865 Jul 6, 2020
@golang golang locked and limited conversation to collaborators Jul 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants