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/gopls: mutex deadlock #33992

Closed
muirdm opened this issue Aug 30, 2019 · 2 comments
Closed

x/tools/gopls: mutex deadlock #33992

muirdm opened this issue Aug 30, 2019 · 2 comments
Labels
Milestone

Comments

@muirdm
Copy link

@muirdm muirdm commented Aug 30, 2019

I hit another mutex deadlock today. It boils down to these conflicting acquisition orders:

(*goFile).isDirty acquires goFile.mu
(*fileBase).Handle acquires fileBase.handleMu

(*view).SetContent acquires view.mu
(*goFile).invalidateContent acquires goFile.handleMu
(*view).remove acquires goFile.mu

Below are the full stack traces for the two goroutines.

1 @ 0x1030baf 0x1040f29 0x1040eff 0x1040c9d 0x1073469 0x1559af2 0x155b923 0x155a8e4 0x155ace3 0x137eaa4 0x1545439 0x1553ce4 0x105d7e1
#	0x1040c9c	sync.runtime_SemacquireMutex+0x3c						/usr/local/go/src/runtime/sema.go:71
#	0x1073468	sync.(*Mutex).Lock+0x108							/usr/local/go/src/sync/mutex.go:134
#	0x1559af1	golang.org/x/tools/internal/lsp/cache.(*fileBase).Handle+0x41			/Users/muir/projects/tools/internal/lsp/cache/file.go:58
#	0x155b922	golang.org/x/tools/internal/lsp/cache.(*goFile).isDirty+0x102			/Users/muir/projects/tools/internal/lsp/cache/gofile.go:241
#	0x155a8e3	golang.org/x/tools/internal/lsp/cache.(*goFile).GetCheckPackageHandles+0x163	/Users/muir/projects/tools/internal/lsp/cache/gofile.go:130
#	0x155ace2	golang.org/x/tools/internal/lsp/cache.(*goFile).GetCheckPackageHandle+0x42	/Users/muir/projects/tools/internal/lsp/cache/gofile.go:150
#	0x137eaa3	golang.org/x/tools/internal/lsp/source.Diagnostics+0x1b3			/Users/muir/projects/tools/internal/lsp/source/diagnostics.go:73
#	0x1545438	golang.org/x/tools/internal/lsp.(*Server).Diagnostics+0x1f8			/Users/muir/projects/tools/internal/lsp/diagnostics.go:30
#	0x1553ce3	golang.org/x/tools/internal/lsp.(*Server).didChange.func1+0xf3			/Users/muir/projects/tools/internal/lsp/text_synchronization.go:90

1 @ 0x1030baf 0x1040f29 0x1040eff 0x1040c9d 0x1073469 0x1566b74 0x15668d3 0x15666d2 0x156955e 0x15681f0 0x1568edd 0x1563110 0x156659d 0x1550d69 0x154dd19 0x1323597 0x118699a 0x105d7e1
#	0x1040c9c	sync.runtime_SemacquireMutex+0x3c					/usr/local/go/src/runtime/sema.go:71
#	0x1073468	sync.(*Mutex).Lock+0x108						/usr/local/go/src/sync/mutex.go:134
#	0x1566b73	golang.org/x/tools/internal/lsp/cache.(*view).remove+0x273		/Users/muir/projects/tools/internal/lsp/cache/view.go:418
#	0x15668d2	golang.org/x/tools/internal/lsp/cache.(*goFile).invalidateAST+0x192	/Users/muir/projects/tools/internal/lsp/cache/view.go:385
#	0x15666d1	golang.org/x/tools/internal/lsp/cache.(*goFile).invalidateContent+0xd1	/Users/muir/projects/tools/internal/lsp/cache/view.go:371
#	0x156955d	golang.org/x/tools/internal/lsp/cache.(*view).getFile.func1+0x4d	/Users/muir/projects/tools/internal/lsp/cache/view.go:493
#	0x15681ef	golang.org/x/tools/internal/lsp/cache.(*WatchMap).Notify+0x14f		/Users/muir/projects/tools/internal/lsp/cache/watcher.go:60
#	0x1568edc	golang.org/x/tools/internal/lsp/cache.(*session).SetOverlay.func1+0x6c	/Users/muir/projects/tools/internal/lsp/cache/session.go:259
#	0x156310f	golang.org/x/tools/internal/lsp/cache.(*session).SetOverlay+0x1ff	/Users/muir/projects/tools/internal/lsp/cache/session.go:277
#	0x156659c	golang.org/x/tools/internal/lsp/cache.(*view).SetContent+0x15c		/Users/muir/projects/tools/internal/lsp/cache/view.go:355
#	0x1550d68	golang.org/x/tools/internal/lsp.(*Server).didChange+0x238		/Users/muir/projects/tools/internal/lsp/text_synchronization.go:71
#	0x154dd18	golang.org/x/tools/internal/lsp.(*Server).DidChange+0x48		/Users/muir/projects/tools/internal/lsp/server.go:155
#	0x1323596	golang.org/x/tools/internal/lsp/protocol.serverHandler.Deliver+0x2606	/Users/muir/projects/tools/internal/lsp/protocol/tsserver.go:122
#	0x1186999	golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1+0x139		/Users/muir/projects/tools/internal/jsonrpc2/jsonrpc2.go:370
@gopherbot gopherbot added this to the Unreleased milestone Aug 30, 2019
@gopherbot gopherbot added the gopls label Aug 30, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Aug 30, 2019

Thank you for filing a gopls issue! Please take a look at the Troubleshooting section of the gopls Wiki page, and make sure that you have provided all of the relevant information here.

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Sep 4, 2019

Change https://golang.org/cl/193317 mentions this issue: internal/lsp: fix deadlock in type-checking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.