You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/go: gccCompilerID cache validation always fails due to a trailing NUL field #81553
Read the compiler ID cache validation in gccCompilerID (src/cmd/go/internal/work/exec.go). The cache entry is written as pairs of filename \x00 statinfo \x00 followed by the compiler ID, and validated on read like this:
stats:=strings.Split(string(data[:len(data)-len(id)]), "\x00")
iflen(stats)%2!=0 {
goto Miss
}
What did you see happen?
The payload itself ends with a NUL byte, so the split always produces a trailing empty field and an odd number of fields, and validation always takes goto Miss. The cached compiler ID is never reused: every go process that needs it re-runs the C compiler via gccToolID, which is the expense this cache was added to avoid (CL 392454, Go 1.19).
The loop below the parity check also advances by one over the name/stat pairs (i++ rather than i += 2), so an entry recording two files would fail validation even with the parity check fixed.
What did you expect to see?
A cache hit: repeated go invocations should validate the entry with os.Stat and reuse the stored compiler ID without re-running the compiler.
Activity
gopherbot commentedon Sep 15, 2026
Change https://go.dev/cl/833424 mentions this issue:
cmd/go: fix gccCompilerID cache validation