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: call to IsGenerated ocassionally has nil Snapshot causing panic #41778

kortschak opened this issue Oct 4, 2020 · 3 comments


Copy link

@kortschak kortschak commented Oct 4, 2020

What did you do?

This is sporadic, and I'm not entirely sure how to reliably repoduce it; my current approach to reproduction is to to open new files and make modifications. About 1/20 times, this will cause this crash.

I am using gopls with sublimelsp/LSP as recommended. ST3.

What did you expect to see?

No crash.

What did you see instead?

A crash.

gopls: panic: runtime error: invalid memory address or nil pointer dereference
gopls: [signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x7e4dba]
gopls: goroutine 14460 [running]:
gopls:, 0xc001af7140, 0x0, 0x0, 0xc013a48100, 0x32, 0x0)
gopls: /home/user/src/ +0x3a
gopls:*Server).didModifyFiles(0xc00010cbb0, 0xef2aa0, 0xc001af7140, 0xc020b65ef0, 0x1, 0x1, 0x1, 0x0, 0x0)
gopls: /home/user/src/ +0xecf
gopls:*Server).didChange(0xc00010cbb0, 0xef2aa0, 0xc001af7140, 0xc017c50300, 0x0, 0x0)
gopls: /home/user/src/ +0x266
gopls:*Server).DidChange(0xc00010cbb0, 0xef2aa0, 0xc001af7140, 0xc017c50300, 0xc017c50300, 0x0)
gopls: /home/user/src/ +0x49
gopls:, 0xc001af7140, 0xf065e0, 0xc00010cbb0, 0xc017c502d0, 0x7fc32cee4040, 0xc001af66f0, 0x0, 0xedff00, 0xc02e7d2dc0)
gopls: /home/user/src/ +0x1a7e
gopls:, 0xc001af7140, 0xc017c502d0, 0x7fc32cee4040, 0xc001af66f0, 0x20af386554, 0x134ade0)
gopls: /home/user/src/ +0xc5
gopls:, 0xc001af7140, 0xc017c502d0, 0x7fc32cee4040, 0xc001af66f0, 0x0, 0x0)
gopls: /home/user/src/ +0x452
gopls:, 0xc001af7140, 0xc0225f27e0, 0x7fc32cee4040, 0xc001af66f0, 0xc00a2cc4b0, 0xe17fc0)
gopls: /home/user/src/ +0xcf
gopls:, 0xc017c85260, 0xc0006ba210, 0xef2aa0, 0xc001af7140, 0xc0225f27e0, 0x7fc32cee4040, 0xc001af66f0)
gopls: /home/user/src/ +0x86
gopls: created by
gopls: /home/user/src/ +0x173

This is a consequence of filling snapshotByURI with nil Snaphots here and then if a snapshot value is nil here leaving it there. Finally, the check for valid snaphots here uses map presence rather than Snapshot nil-ness as the check for validity.

Either the validity check in the generated code check loop should be for non-nil Snapshots

		snapshot := snapshotByURI[mod.URI]
		if snapshot == nil {

or probably better, remove the snapshotByURI elements that are nil in the check above.

		// If the file isn't in any known views (for example, if it's in a dependency),
		// we may not have a snapshot to map it to. As a result, we won't try to
		// diagnose it. TODO(rstambler): Figure out how to handle this better.
		if snapshot == nil {
			delete(snapshotByURI, uri)

Maybe both.

Build info

golang/tools@9647ced v0.5.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k= h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= => ../ h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k= h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ= h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
@gopherbot gopherbot added this to the Unreleased milestone Oct 4, 2020
Copy link

@stamblerre stamblerre commented Oct 4, 2020

Thank you for this report! I think this bug has been around for a while, but it was actually just reported by someone else, so I will close this as a duplicate of #41777.

@stamblerre stamblerre closed this Oct 4, 2020
Copy link

@stamblerre stamblerre commented Oct 4, 2020

Duplicate of #41777

@stamblerre stamblerre marked this as a duplicate of #41777 Oct 4, 2020
Copy link

@cespare cespare commented Oct 4, 2020

Well that's quite the coincidence.

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

Successfully merging a pull request may close this issue.

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