Skip to content

Commit

Permalink
gopls/internal/server: fix crash in SignatureHelp
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
findleyr authored and gopherbot committed Mar 11, 2024
1 parent 176e895 commit f89da53
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 f89da53

Please sign in to comment.