Skip to content

Commit 7df6af8

Browse files
committed
gopls/internal/lsp/filecache: silently discard CRC errors on macOS
On macOS we observe builder panics caused by CRC failures reading filecache entries: the checksum is all zero but the rest is fine. The underlying cause is still a mystery: lockedfile.Write(name, io.MultiReader(len, val, checksum)) results in three write system calls to the locked *os.File, so while it is natural that we might observe fewer than three portions of the file if the process is interrupted, it doesn't explain why we might see the third portion existing with the wrong value. I suspect a macOS file system bug. Fixes golang/go#59895 Change-Id: I43d0765b37d695cce0919425f6a919623da1ee46 Reviewed-on: https://go-review.googlesource.com/c/tools/+/492035 Run-TryBot: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]> Reviewed-by: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent 2563079 commit 7df6af8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

gopls/internal/lsp/filecache/filecache.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"log"
3434
"os"
3535
"path/filepath"
36+
"runtime"
3637
"sort"
3738
"sync"
3839
"sync/atomic"
@@ -81,7 +82,16 @@ func Get(kind string, key [32]byte) ([]byte, error) {
8182
// issue #59289. TODO(adonovan): stop printing the entire file
8283
// once we've seen enough reports to understand the pattern.
8384
if binary.LittleEndian.Uint32(checksum) != crc32.ChecksumIEEE(value) {
84-
return nil, bug.Errorf("internal error in filecache.Get(%q, %x): invalid checksum at end of %d-byte file %s:\n%q",
85+
// Darwin has repeatedly displayed a problem (#59895)
86+
// whereby the checksum portion (and only it) is zero,
87+
// which suggests a bug in its file system . Don't
88+
// panic, but keep an eye on other failures for now.
89+
errorf := bug.Errorf
90+
if binary.LittleEndian.Uint32(checksum) == 0 && runtime.GOOS == "darwin" {
91+
errorf = fmt.Errorf
92+
}
93+
94+
return nil, errorf("internal error in filecache.Get(%q, %x): invalid checksum at end of %d-byte file %s:\n%q",
8595
kind, key, len(data), name, data)
8696
}
8797

0 commit comments

Comments
 (0)