avoid a filesystem race with build cache entries
After the last commit, I started seeing seemingly random test failures: --- FAIL: TestScripts/cgo (1.17s) testscript.go:397: > env GOPRIVATE=test/main > garble build [stderr] # runtime/internal/math EOF # internal/bytealg EOF exit status 2 [exit status 1] FAIL: testdata/scripts/cgo.txt:3: unexpected command failure --- FAIL: TestScripts/reflect (8.63s) testscript.go:397: > env GOPRIVATE=test/main > garble build [stderr] # math EOF exit status 2 [exit status 1] FAIL: testdata/scripts/reflect.txt:3: unexpected command failure --- FAIL: TestScripts/linkname (8.72s) testscript.go:397: > env GOPRIVATE=test/main > garble build [stderr] # math EOF exit status 2 [exit status 1] FAIL: testdata/scripts/linkname.txt:3: unexpected command failure After some investigation, it turned out that concurrent "garble build" processes were writing to the same build cache paths at the same time. This is effectively a filesystem race, and encoding/gob could error when reading partly written files. To fix this problem, use a cache path that changes according to the obfuscated build. See garbleExportFile. Note that the data we store in that file does not vary with obfuscation. We could fix the filesystem race by adding locking around the old path. However, we'll want to cache data that does vary with garble flags, such as the -debugdir source code.pull/400/head
parent
8d162dcd04
commit
08ec70e9a9
Loading…
Reference in New Issue