Skip to content

Commit ba252e8

Browse files
findleyrgopherbot
authored andcommitted
[gopls-release-branch.0.15] gopls/internal/server: fix crash in SignatureHelp
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 <[email protected]> Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> (cherry picked from commit f89da53) Reviewed-on: https://go-review.googlesource.com/c/tools/+/570596
1 parent 3a44541 commit ba252e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gopls/internal/server/signature_help.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ func (s *server) SignatureHelp(ctx context.Context, params *protocol.SignatureHe
1919
defer done()
2020

2121
fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI)
22-
defer release()
2322
if err != nil {
2423
return nil, err
2524
}
25+
defer release()
2626

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

0 commit comments

Comments
 (0)