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

go/types, types2: data race to interface typeset #61561

Closed
findleyr opened this issue Jul 25, 2023 · 11 comments
Closed

go/types, types2: data race to interface typeset #61561

findleyr opened this issue Jul 25, 2023 · 11 comments
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done.

Comments

@findleyr
Copy link
Contributor

findleyr commented Jul 25, 2023

Discovered in the trybot failures of https://go.dev/cl/512636.

There's a data race to interface type set computation. I don't know how it's gone undetected for so long: the interface type set is unguarded, and instantiated interfaces are not completed.
https://cs.opensource.google/go/go/+/master:src/go/types/interface.go;l=29;drc=97f843b51f69f392bb09b24c077aca505e519551

Whatever the fix, I think we should consider back porting to 1.21+1.20.

CC @griesemer

@findleyr findleyr added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 25, 2023
@findleyr
Copy link
Contributor Author

Connecting the dots: I think this may be the cause of some confusing diagnostics users have reported in gopls. (e.g. https://gophers.slack.com/archives/C2B4L99RS/p1686512574586319)

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/512636 mentions this issue: gopls/internal/lsp/cache: memoize active packages after every operation

@bcmills
Copy link
Contributor

bcmills commented Jul 25, 2023

race reports from the TryBot log
==================
WARNING: DATA RACE
Read at 0x00c0052140e8 by goroutine 34355:
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:155 +0x6e
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0xc4f
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0x6d7
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.(*indexBuilder).build()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:245 +0x704
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.NewIndex()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:82 +0x50
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1.(*syntaxPackage).methodsets.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:74 +0x7a
  sync.(*Once).doSlow()
      /workdir/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /workdir/go/src/sync/once.go:65 +0x44
  golang.org/x/tools/gopls/internal/lsp/cache.(*syntaxPackage).methodsets()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:73 +0x20f
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:661 +0x1df

Previous write at 0x00c0052140e8 by goroutine 34345:
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:194 +0x404
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0xc4f
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0x6d7
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.KeyOf()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:103 +0xc6e
  golang.org/x/tools/gopls/internal/lsp/source.implementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:147 +0xc30
  golang.org/x/tools/gopls/internal/lsp/source.Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:52 +0x114
  golang.org/x/tools/gopls/internal/lsp.(*Server).implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/implementation.go:25 +0x2d2
  golang.org/x/tools/gopls/internal/lsp.(*Server).Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/server_gen.go:140 +0x44
  golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/tsserver.go:407 +0x5a7e
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:157 +0xae
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/lsprpc/lsprpc.go:519 +0xb83
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:35 +0x18b
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:103 +0xb1

Goroutine 34355 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:658 +0x431
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).handleSyntaxPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:512 +0x52c
  golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackageInternal.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:374 +0x74
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76

Goroutine 34345 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:100 +0x38e
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.CancelHandler.CancelHandler.func4()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:69 +0x2a9
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.CancelHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:249 +0x136
  golang.org/x/tools/internal/jsonrpc2.(*conn).run()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/conn.go:218 +0xab9
  golang.org/x/tools/internal/jsonrpc2.(*conn).Go.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/conn.go:189 +0x5d
==================
==================
WARNING: DATA RACE
Read at 0x00c0047b53c0 by goroutine 34355:
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0xc5e
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.(*indexBuilder).build()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:245 +0x704
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.NewIndex()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:82 +0x50
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1.(*syntaxPackage).methodsets.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:74 +0x7a
  sync.(*Once).doSlow()
      /workdir/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /workdir/go/src/sync/once.go:65 +0x44
  golang.org/x/tools/gopls/internal/lsp/cache.(*syntaxPackage).methodsets()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:73 +0x20f
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:661 +0x1df

Previous write at 0x00c0047b53c0 by goroutine 34345:
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:194 +0x31e
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0xc4f
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0x6d7
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.KeyOf()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:103 +0xc6e
  golang.org/x/tools/gopls/internal/lsp/source.implementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:147 +0xc30
  golang.org/x/tools/gopls/internal/lsp/source.Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:52 +0x114
  golang.org/x/tools/gopls/internal/lsp.(*Server).implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/implementation.go:25 +0x2d2
  golang.org/x/tools/gopls/internal/lsp.(*Server).Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/server_gen.go:140 +0x44
  golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/tsserver.go:407 +0x5a7e
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:157 +0xae
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/lsprpc/lsprpc.go:519 +0xb83
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:35 +0x18b
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:103 +0xb1

Goroutine 34355 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:658 +0x431
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).handleSyntaxPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:512 +0x52c
  golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackageInternal.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:374 +0x74
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76

Goroutine 34345 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:100 +0x38e
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.CancelHandler.CancelHandler.func4()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:69 +0x2a9
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.CancelHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:249 +0x136
  golang.org/x/tools/internal/jsonrpc2.(*conn).run()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/conn.go:218 +0xab9
  golang.org/x/tools/internal/jsonrpc2.(*conn).Go.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/conn.go:189 +0x5d
==================
==================
WARNING: DATA RACE
Read at 0x00c00551ca18 by goroutine 34355:
  go/types.methodSet.add()
      /workdir/go/src/go/types/methodset.go:222 +0x116
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0xca8
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.(*indexBuilder).build()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:245 +0x704
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.NewIndex()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:82 +0x50
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1.(*syntaxPackage).methodsets.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:74 +0x7a
  sync.(*Once).doSlow()
      /workdir/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /workdir/go/src/sync/once.go:65 +0x44
  golang.org/x/tools/gopls/internal/lsp/cache.(*syntaxPackage).methodsets()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:73 +0x20f
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:661 +0x1df

Previous write at 0x00c00551ca18 by goroutine 34345:
  go/types.computeInterfaceTypeSet.func2()
      /workdir/go/src/go/types/typeset.go:226 +0x954
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:257 +0x757
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0xc4f
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0x6d7
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.KeyOf()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:103 +0xc6e
  golang.org/x/tools/gopls/internal/lsp/source.implementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:147 +0xc30
  golang.org/x/tools/gopls/internal/lsp/source.Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:52 +0x114
  golang.org/x/tools/gopls/internal/lsp.(*Server).implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/implementation.go:25 +0x2d2
  golang.org/x/tools/gopls/internal/lsp.(*Server).Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/server_gen.go:140 +0x44
  golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/tsserver.go:407 +0x5a7e
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:157 +0xae
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/lsprpc/lsprpc.go:519 +0xb83
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:35 +0x18b
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:103 +0xb1

Goroutine 34355 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:658 +0x431
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).handleSyntaxPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:512 +0x52c
  golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackageInternal.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:374 +0x74
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76

Goroutine 34345 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:100 +0x38e
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.CancelHandler.CancelHandler.func4()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:69 +0x2a9
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.CancelHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:249 +0x136
  golang.org/x/tools/internal/jsonrpc2.(*conn).run()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/conn.go:218 +0xab9
  golang.org/x/tools/internal/jsonrpc2.(*conn).Go.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/conn.go:189 +0x5d
==================
==================
WARNING: DATA RACE
Read at 0x00c004ed14e8 by goroutine 34390:
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:155 +0x6e
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0x64
  go/types.(*Interface).Empty()
      /workdir/go/src/go/types/interface.go:120 +0x12
  go/types.(*Checker).implements()
      /workdir/go/src/go/types/instantiate.go:224 +0x66a
  go/types.(*operand).assignableTo()
      /workdir/go/src/go/types/operand.go:284 +0x52c
  go/types.AssignableTo()
      /workdir/go/src/go/types/api.go:451 +0x108
  golang.org/x/tools/gopls/internal/lsp/source.concreteImplementsIntf()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:443 +0x12
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:342 +0x44b
  go/ast.inspector.Visit()
      /workdir/go/src/go/ast/walk.go:386 +0x3a
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:51 +0x82
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:344 +0x27d1
  go/ast.walkDeclList()
      /workdir/go/src/go/ast/walk.go:38 +0x2724
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:366 +0x24eb
  go/ast.Inspect()
      /workdir/go/src/go/ast/walk.go:397 +0x224
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:322 +0x1f9
  golang.org/x/tools/gopls/internal/lsp/source.implementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:190 +0x124
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76

Previous write at 0x00c004ed14e8 by goroutine 34387:
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:194 +0x404
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0xc4f
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0x6d7
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.(*indexBuilder).build()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:245 +0x704
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.NewIndex()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:82 +0x50
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1.(*syntaxPackage).methodsets.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:74 +0x7a
  sync.(*Once).doSlow()
      /workdir/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /workdir/go/src/sync/once.go:65 +0x44
  golang.org/x/tools/gopls/internal/lsp/cache.(*syntaxPackage).methodsets()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:73 +0x20f
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:661 +0x1df

Goroutine 34390 (running) created at:
  golang.org/x/sync/errgroup.(*Group).Go()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:72 +0x124
  golang.org/x/tools/gopls/internal/lsp/source.implementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:189 +0x17ba
  golang.org/x/tools/gopls/internal/lsp/source.Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:52 +0x114
  golang.org/x/tools/gopls/internal/lsp.(*Server).implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/implementation.go:25 +0x2d2
  golang.org/x/tools/gopls/internal/lsp.(*Server).Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/server_gen.go:140 +0x44
  golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/tsserver.go:407 +0x5a7e
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:157 +0xae
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/lsprpc/lsprpc.go:519 +0xb83
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:35 +0x18b
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:103 +0xb1

Goroutine 34387 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:658 +0x431
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).handleSyntaxPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:512 +0x52c
  golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackageInternal.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:374 +0x74
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76
==================
==================
WARNING: DATA RACE
Read at 0x00c004c81570 by goroutine 34390:
  go/types.(*_TypeSet).IsMethodSet()
      /workdir/go/src/go/types/typeset.go:40 +0x77
  go/types.(*_TypeSet).IsAll()
      /workdir/go/src/go/types/typeset.go:37 +0xc5
  go/types.(*Interface).Empty()
      /workdir/go/src/go/types/interface.go:120 +0x12
  go/types.(*Checker).implements()
      /workdir/go/src/go/types/instantiate.go:224 +0x66a
  go/types.(*operand).assignableTo()
      /workdir/go/src/go/types/operand.go:284 +0x52c
  go/types.AssignableTo()
      /workdir/go/src/go/types/api.go:451 +0x108
  golang.org/x/tools/gopls/internal/lsp/source.concreteImplementsIntf()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:443 +0x12
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:342 +0x44b
  go/ast.inspector.Visit()
      /workdir/go/src/go/ast/walk.go:386 +0x3a
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:51 +0x82
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:344 +0x27d1
  go/ast.walkDeclList()
      /workdir/go/src/go/ast/walk.go:38 +0x2724
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:366 +0x24eb
  go/ast.Inspect()
      /workdir/go/src/go/ast/walk.go:397 +0x224
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:322 +0x1f9
  golang.org/x/tools/gopls/internal/lsp/source.implementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:190 +0x124
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76

Previous write at 0x00c004c81570 by goroutine 34387:
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:194 +0x31e
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0xc4f
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0x6d7
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.(*indexBuilder).build()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:245 +0x704
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.NewIndex()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:82 +0x50
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1.(*syntaxPackage).methodsets.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:74 +0x7a
  sync.(*Once).doSlow()
      /workdir/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /workdir/go/src/sync/once.go:65 +0x44
  golang.org/x/tools/gopls/internal/lsp/cache.(*syntaxPackage).methodsets()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:73 +0x20f
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:661 +0x1df

Goroutine 34390 (running) created at:
  golang.org/x/sync/errgroup.(*Group).Go()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:72 +0x124
  golang.org/x/tools/gopls/internal/lsp/source.implementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:189 +0x17ba
  golang.org/x/tools/gopls/internal/lsp/source.Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:52 +0x114
  golang.org/x/tools/gopls/internal/lsp.(*Server).implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/implementation.go:25 +0x2d2
  golang.org/x/tools/gopls/internal/lsp.(*Server).Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/server_gen.go:140 +0x44
  golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/tsserver.go:407 +0x5a7e
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:157 +0xae
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/lsprpc/lsprpc.go:519 +0xb83
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:35 +0x18b
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:103 +0xb1

Goroutine 34387 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:658 +0x431
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).handleSyntaxPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:512 +0x52c
  golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackageInternal.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:374 +0x74
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76
==================
==================
WARNING: DATA RACE
Read at 0x00c004c81558 by goroutine 34390:
  go/types.(*_TypeSet).IsMethodSet()
      /workdir/go/src/go/types/typeset.go:40 +0x8e
  go/types.(*_TypeSet).IsAll()
      /workdir/go/src/go/types/typeset.go:37 +0xc5
  go/types.(*Interface).Empty()
      /workdir/go/src/go/types/interface.go:120 +0x12
  go/types.(*Checker).implements()
      /workdir/go/src/go/types/instantiate.go:224 +0x66a
  go/types.(*operand).assignableTo()
      /workdir/go/src/go/types/operand.go:284 +0x52c
  go/types.AssignableTo()
      /workdir/go/src/go/types/api.go:451 +0x108
  golang.org/x/tools/gopls/internal/lsp/source.concreteImplementsIntf()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:443 +0x12
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:342 +0x44b
  go/ast.inspector.Visit()
      /workdir/go/src/go/ast/walk.go:386 +0x3a
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:51 +0x82
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:344 +0x27d1
  go/ast.walkDeclList()
      /workdir/go/src/go/ast/walk.go:38 +0x2724
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:366 +0x24eb
  go/ast.Inspect()
      /workdir/go/src/go/ast/walk.go:397 +0x224
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:322 +0x1f9
  golang.org/x/tools/gopls/internal/lsp/source.implementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:190 +0x124
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76

Previous write at 0x00c004c81558 by goroutine 34387:
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:194 +0x31e
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0xc4f
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0x6d7
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.(*indexBuilder).build()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:245 +0x704
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.NewIndex()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:82 +0x50
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1.(*syntaxPackage).methodsets.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:74 +0x7a
  sync.(*Once).doSlow()
      /workdir/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /workdir/go/src/sync/once.go:65 +0x44
  golang.org/x/tools/gopls/internal/lsp/cache.(*syntaxPackage).methodsets()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:73 +0x20f
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:661 +0x1df

Goroutine 34390 (running) created at:
  golang.org/x/sync/errgroup.(*Group).Go()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:72 +0x124
  golang.org/x/tools/gopls/internal/lsp/source.implementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:189 +0x17ba
  golang.org/x/tools/gopls/internal/lsp/source.Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:52 +0x114
  golang.org/x/tools/gopls/internal/lsp.(*Server).implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/implementation.go:25 +0x2d2
  golang.org/x/tools/gopls/internal/lsp.(*Server).Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/server_gen.go:140 +0x44
  golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/tsserver.go:407 +0x5a7e
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:157 +0xae
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/lsprpc/lsprpc.go:519 +0xb83
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:35 +0x18b
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:103 +0xb1

Goroutine 34387 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:658 +0x431
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).handleSyntaxPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:512 +0x52c
  golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackageInternal.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:374 +0x74
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76
==================
==================
WARNING: DATA RACE
Read at 0x00c004c81540 by goroutine 34390:
  go/types.(*_TypeSet).IsAll()
      /workdir/go/src/go/types/typeset.go:37 +0x149
  go/types.(*Interface).Empty()
      /workdir/go/src/go/types/interface.go:120 +0x12
  go/types.(*Checker).implements()
      /workdir/go/src/go/types/instantiate.go:224 +0x66a
  go/types.(*operand).assignableTo()
      /workdir/go/src/go/types/operand.go:284 +0x52c
  go/types.AssignableTo()
      /workdir/go/src/go/types/api.go:451 +0x108
  golang.org/x/tools/gopls/internal/lsp/source.concreteImplementsIntf()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:443 +0x12
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:342 +0x44b
  go/ast.inspector.Visit()
      /workdir/go/src/go/ast/walk.go:386 +0x3a
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:51 +0x82
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:344 +0x27d1
  go/ast.walkDeclList()
      /workdir/go/src/go/ast/walk.go:38 +0x2724
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:366 +0x24eb
  go/ast.Inspect()
      /workdir/go/src/go/ast/walk.go:397 +0x224
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:322 +0x1f9
  golang.org/x/tools/gopls/internal/lsp/source.implementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:190 +0x124
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76

Previous write at 0x00c004c81540 by goroutine 34387:
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:194 +0x31e
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0xc4f
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0x6d7
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.(*indexBuilder).build()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:245 +0x704
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.NewIndex()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:82 +0x50
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1.(*syntaxPackage).methodsets.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:74 +0x7a
  sync.(*Once).doSlow()
      /workdir/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /workdir/go/src/sync/once.go:65 +0x44
  golang.org/x/tools/gopls/internal/lsp/cache.(*syntaxPackage).methodsets()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:73 +0x20f
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:661 +0x1df

Goroutine 34390 (running) created at:
  golang.org/x/sync/errgroup.(*Group).Go()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:72 +0x124
  golang.org/x/tools/gopls/internal/lsp/source.implementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:189 +0x17ba
  golang.org/x/tools/gopls/internal/lsp/source.Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:52 +0x114
  golang.org/x/tools/gopls/internal/lsp.(*Server).implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/implementation.go:25 +0x2d2
  golang.org/x/tools/gopls/internal/lsp.(*Server).Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/server_gen.go:140 +0x44
  golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/tsserver.go:407 +0x5a7e
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:157 +0xae
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/lsprpc/lsprpc.go:519 +0xb83
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:35 +0x18b
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:103 +0xb1

Goroutine 34387 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:658 +0x431
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).handleSyntaxPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:512 +0x52c
  golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackageInternal.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:374 +0x74
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76
==================
==================
WARNING: DATA RACE
Read at 0x00c000f5dd70 by goroutine 34390:
  go/types.(*Checker).missingMethod()
      /workdir/go/src/go/types/lookup.go:377 +0xecc
  go/types.(*Checker).implements()
      /workdir/go/src/go/types/instantiate.go:246 +0x9f7
  go/types.(*operand).assignableTo()
      /workdir/go/src/go/types/operand.go:284 +0x52c
  go/types.AssignableTo()
      /workdir/go/src/go/types/api.go:451 +0x108
  golang.org/x/tools/gopls/internal/lsp/source.concreteImplementsIntf()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:443 +0x12
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:342 +0x44b
  go/ast.inspector.Visit()
      /workdir/go/src/go/ast/walk.go:386 +0x3a
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:51 +0x82
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:344 +0x27d1
  go/ast.walkDeclList()
      /workdir/go/src/go/ast/walk.go:38 +0x2724
  go/ast.Walk()
      /workdir/go/src/go/ast/walk.go:366 +0x24eb
  go/ast.Inspect()
      /workdir/go/src/go/ast/walk.go:397 +0x224
  golang.org/x/tools/gopls/internal/lsp/source.localImplementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:322 +0x1f9
  golang.org/x/tools/gopls/internal/lsp/source.implementations.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:190 +0x124
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76

Previous write at 0x00c000f5dd70 by goroutine 34387:
  go/types.computeInterfaceTypeSet.func2()
      /workdir/go/src/go/types/typeset.go:226 +0x954
  go/types.computeInterfaceTypeSet()
      /workdir/go/src/go/types/typeset.go:257 +0x757
  go/types.(*Interface).typeSet()
      /workdir/go/src/go/types/interface.go:29 +0xc4f
  go/types.NewMethodSet()
      /workdir/go/src/go/types/methodset.go:158 +0x6d7
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.methodSetInfo()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:278 +0x84
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.(*indexBuilder).build()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:245 +0x704
  golang.org/x/tools/gopls/internal/lsp/source/methodsets.NewIndex()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/methodsets/methodsets.go:82 +0x50
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1.(*syntaxPackage).methodsets.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:74 +0x7a
  sync.(*Once).doSlow()
      /workdir/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /workdir/go/src/sync/once.go:65 +0x44
  golang.org/x/tools/gopls/internal/lsp/cache.(*syntaxPackage).methodsets()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/pkg.go:73 +0x20f
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage.func1()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:661 +0x1df

Goroutine 34390 (running) created at:
  golang.org/x/sync/errgroup.(*Group).Go()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:72 +0x124
  golang.org/x/tools/gopls/internal/lsp/source.implementations()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:189 +0x17ba
  golang.org/x/tools/gopls/internal/lsp/source.Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/source/implementation.go:52 +0x114
  golang.org/x/tools/gopls/internal/lsp.(*Server).implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/implementation.go:25 +0x2d2
  golang.org/x/tools/gopls/internal/lsp.(*Server).Implementation()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/server_gen.go:140 +0x44
  golang.org/x/tools/gopls/internal/lsp/protocol.serverDispatch()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/tsserver.go:407 +0x5a7e
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.ServerHandler.func3()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/protocol/protocol.go:157 +0xae
  golang.org/x/tools/gopls/internal/lsp/lsprpc.(*StreamServer).ServeStream.handshaker.func4()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/lsprpc/lsprpc.go:519 +0xb83
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.MustReplyHandler.func1()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:35 +0x18b
  golang.org/x/tools/gopls/internal/lsp/protocol.Handlers.AsyncHandler.func2.2()
      /workdir/gopath/src/golang.org/x/tools/internal/jsonrpc2/handler.go:103 +0xb1

Goroutine 34387 (running) created at:
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).checkPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:658 +0x431
  golang.org/x/tools/gopls/internal/lsp/cache.(*typeCheckBatch).handleSyntaxPackage()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:512 +0x52c
  golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackageInternal.func2()
      /workdir/gopath/src/golang.org/x/tools/gopls/internal/lsp/cache/check.go:374 +0x74
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /workdir/gopath/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75 +0x76
==================

@bcmills
Copy link
Contributor

bcmills commented Jul 25, 2023

As I understand it, this is too recent to explain #37602?

@findleyr
Copy link
Contributor Author

@bcmills this race has existed from the beginning (go 1.18).

I'm shocked that it hasn't been uncovered until now, though it does explain multiple confusing observations in gopls, which may be one of the few concurrent users of go/types.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/512955 mentions this issue: internal/gcimporter: another workaround for race to interface type set

gopherbot pushed a commit to golang/tools that referenced this issue Jul 25, 2023
We were memoizing active packages only after a call to TypeCheck. This
means that we may duplicate work if diagnostics, references, or
implements requests execute before the first call to TypeCheck for an
open package.

Fix this by pushing the memoization logic down into forEachPackage.

This uncovered a bug in go/types that may have already been affecting
users: golang/go#61561. This bug is consistent with user reports on
slack of strange errors related to missing methods.

Avoid this bug in most cases by ensuring that all instantiated
interfaces are completed immediately after type checking. However, this
doesn't completely avoid the bug as it may not complete parameterized
interface literals elsewhere in the type definition. For example, the
following definition is still susceptible to the bug:

type T[P any] interface { m() interface{ n(P) } }

For golang/go#60926
Fixes golang/go#61005

Change-Id: I324cd13bac7c17b1eb5642973157bdbfb2368650
Reviewed-on: https://go-review.googlesource.com/c/tools/+/512636
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
gopherbot pushed a commit to golang/tools that referenced this issue Jul 25, 2023
When importing, it is also possible to produce an incomplete interface
instance, which can be racy (as reproduced in the included test).

Partially avoid this by completing interface underlyings of instances.

For golang/go#61561

Change-Id: I8ca2bdc2d03fa1a46179bbd8596d7ef9baf51600
Reviewed-on: https://go-review.googlesource.com/c/tools/+/512955
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
@findleyr findleyr assigned findleyr and griesemer and unassigned griesemer Jul 25, 2023
@findleyr
Copy link
Contributor Author

I believe I have a fix for this. Unfortunately, these types of fixes (in go/types, at least) tend to be risky, so we must be very careful before cherry-picking.

@firelizzard18
Copy link
Contributor

I’ve also seen what I believe is a related failure when running lint in CI. I’ll hunt for the logs tomorrow. I’ve only seen it fail once or twice and it went away when I retried the job.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/513015 mentions this issue: go/types, types2: instantiated interfaces must be concurrency safe

@firelizzard18
Copy link
Contributor

I can't find it now but what I recall is that type checking failed. I use golangci-lint, and I'm pretty sure it was the 'typecheck' linter (which really means the stdlib's go/* packages, not an actual linter/analyzer) that was complaining.

@findleyr
Copy link
Contributor Author

@firelizzard18 thanks, that would make sense given the nature of the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants