Commit 4c03e79ad6 for golang
commit 4c03e79ad6acc786aeb98d313ee55e8e1b1f7f0d
Author: nnnkkk7 <kurodanaoki0711pana@gmail.com>
Date: Sun Nov 15 22:32:06 2026 +0900
cmd/go: fix gccCompilerID cache validation
The description stored in the cache ends with a NUL byte, so
splitting it always gave an odd number of fields and the entry was
never used. The validation loop also advanced by one instead of two.
Fixes #81553
Change-Id: Ief75ef3bcf4bda1b9ca73a8e60d4583f70abfe7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/833424
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
index df4a5a469f..a047c21423 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
@@ -3387,11 +3387,11 @@ func (b *Builder) gccCompilerID(compiler string) (id cache.ActionID, ok bool) {
key := h.Sum()
data, _, err := cache.GetBytes(cache.Default(), key)
if err == nil && len(data) > len(id) {
- stats := strings.Split(string(data[:len(data)-len(id)]), "\x00")
+ stats := strings.Split(string(data[:len(data)-len(id)-1]), "\x00")
if len(stats)%2 != 0 {
goto Miss
}
- for i := 0; i+2 <= len(stats); i++ {
+ for i := 0; i+2 <= len(stats); i += 2 {
info, err := os.Stat(stats[i])
if err != nil || statString(info) != stats[i+1] {
goto Miss