]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/cache: always check error from stat in markUsed
authorMichael Matloob <matloob@golang.org>
Tue, 3 Dec 2024 20:09:41 +0000 (15:09 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 4 Dec 2024 18:20:54 +0000 (18:20 +0000)
commit61232096579d8801cb3513c84a97c141d50ad242
tree66cc52e526d1cfb67f029092dfca01c5b92a15da
parent6f42fe914169ef237423fb07e9c8321884b58c23
cmd/go/internal/cache: always check error from stat in markUsed

markUsed was not checking that the error from os.Stat was nil before
trying to access the FileInfo entry returned by it. Instead, always
check the error and return false if it's non-nil (usually because the
file does not exist). This can happen if an index entry exists in the
cache, but the output entry it points to does not. markUsed is called at
different points for the index entry and for the output entry, so it's
possible for the index entry to be marked used, and then for another go
process to trim the cache, deleting the output entry.  I'm not sure how
likely that is, or if this is what has been triggering the user observed
instances of #70600, but it's enough for a test case.

Fixes #70600

Change-Id: Ia6be14b4a56736d06488ccf93c3596fff8159f22
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/633037
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/go/internal/cache/cache.go
src/cmd/go/testdata/script/list_issue_70600.txt [new file with mode: 0644]