The asynchronous call to processFile is synchronized by the call to
GetExitCode. We can't safely access errBuf until then, because
processFile may still be writing to it.
This is diagnosed by 'go test -race cmd/gofmt', but only the
darwin-amd64-race builder caught it because the other "-race" builders
apparently all run as root (see #10719).
Updates #60225.
Change-Id: Ie66bb4e47429ece81043d6425f26953b7bb26002
Reviewed-on: https://go-review.googlesource.com/c/go/+/496155
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
s.Add(fileWeight(fn, info), func(r *reporter) error {
return processFile(fn, info, nil, r)
})
- if errBuf.Len() > 0 {
- t.Log(errBuf)
- }
if s.GetExitCode() == 0 {
t.Fatal("rewrite of read-only file succeeded unexpectedly")
}
+ if errBuf.Len() > 0 {
+ t.Log(errBuf)
+ }
info, err = os.Stat(fn)
if err != nil {