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: analysis pass is run with missing inputs after one of its dependencies failed => crash #54798

Closed
adonovan opened this issue Aug 31, 2022 · 1 comment
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

When patching https://go-review.git.corp.google.com/c/tools/+/426018/7/internal/lsp/cache/analysis.go, which disables panic recovery, we find a number of nondeterministic panics including this one:

https://source.cloud.google.com/results/invocations/48b434a2-c9e7-46a9-acde-57b5fc976081/targets/golang%2Ftools%2Fgopls-legacy%2Fpresubmit-116/log

panic: interface conversion: interface {} is nil, not *inspector.Inspector

goroutine 65570 [running]:
golang.org/x/tools/go/analysis/passes/structtag.run(0xc00d07f6c0, 0x3, 0xd357a0, 0xc00bc6f701, 0xc00d0b0ef0)
	/src/tools/go/analysis/passes/structtag/structtag.go:37 +0xfe
golang.org/x/tools/internal/lsp/cache.runAnalysis.func8(0xc00d07f6c0, 0xc00bc6f768)
	/src/tools/internal/lsp/cache/analysis.go:376 +0x52
golang.org/x/tools/internal/lsp/cache.runAnalysis(0x1039298, 0xc00d128b40, 0xc0023788c0, 0x149ff00, 0xc008475440, 0xc00d10f680, 0xc00d10f680)
	/src/tools/internal/lsp/cache/analysis.go:377 +0xa56
golang.org/x/tools/internal/lsp/cache.(*snapshot).actionHandle.func1(0x1039298, 0xc00d128b40, 0xe0da60, 0xc0023788c0, 0xc00c133640, 0xc0083d3658)
	/src/tools/internal/lsp/cache/analysis.go:168 +0x159
golang.org/x/tools/internal/memoize.(*Promise).run.func2.1()
	/src/tools/internal/memoize/memoize.go:187 +0xd7
runtime/trace.WithRegion(0x1039298, 0xc00d128b40, 0xc00d122540, 0x21, 0xc0083d3758)
	/usr/local/go/src/runtime/trace/annotation.go:141 +0xf8
golang.org/x/tools/internal/memoize.(*Promise).run.func2(0x1039298, 0xc00d128b40, 0xc00d05d6e0, 0xc00d0b0e80, 0xc00d10e960, 0xe0da60, 0xc0023788c0)
	/src/tools/internal/memoize/memoize.go:180 +0x14c
created by golang.org/x/tools/internal/memoize.(*Promise).run
	/src/tools/internal/memoize/memoize.go:179 +0x19a

I believe the cause is that errors from analysis dependencies are treated as successful results because of sloppy handling of the distinction between (*actionData=nil, err!=nil) and (&actionData{err != nil}, err=nil).

@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 Aug 31, 2022
@gopherbot gopherbot added this to the Unreleased milestone Aug 31, 2022
@gopherbot
Copy link

Change https://go.dev/cl/426800 mentions this issue: internal/lsp/cache: clarify error control flow of analysis

@golang golang locked and limited conversation to collaborators Aug 31, 2023
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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants