Skip to content

Commit

Permalink
[gopls-release-branch.0.15] gopls/internal/server: fix crash in Signa…
Browse files Browse the repository at this point in the history
…tureHelp

Fix a crash when Snapshot.fileOf fails, due to e.g. context
cancellation. The defer of release should only occur after the error is
checked. Unfortunately, this is very hard to test since it likely occurs
only due to races.

This is our first bug found completely via automated crash reporting.

Fixes golang/go#66090

Change-Id: I7c22b5c2d1a0115718cd4bf2b84c31cc38a891ec
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570675
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit f89da53)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/570596
  • Loading branch information
findleyr authored and gopherbot committed Mar 11, 2024
1 parent 3a44541 commit ba252e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gopls/internal/server/signature_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ func (s *server) SignatureHelp(ctx context.Context, params *protocol.SignatureHe
defer done()

fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI)
defer release()
if err != nil {
return nil, err
}
defer release()

if snapshot.FileKind(fh) != file.Go {
return nil, nil // empty result
Expand Down

0 comments on commit ba252e8

Please sign in to comment.