From 5abf395be71e40621d17c6dc5a07aca9ffb5c734 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 7 Jul 2009 10:15:01 -0700 Subject: [PATCH] Avoid race condition. Following the left to right rule, s.output.Data() was being retrieved before the synchronization point, which meant that it could be retrieved before the goroutine wrote it. Using gccgo this caused random errors. R=gri DELTA=2 (1 added, 0 deleted, 1 changed) OCL=31046 CL=31267 --- src/pkg/datafmt/datafmt.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pkg/datafmt/datafmt.go b/src/pkg/datafmt/datafmt.go index 48c24e7264..96dc1d743d 100644 --- a/src/pkg/datafmt/datafmt.go +++ b/src/pkg/datafmt/datafmt.go @@ -745,7 +745,8 @@ func (f Format) Eval(env Environment, args ...) ([]byte, os.Error) { errors <- nil; // no errors }(); - return s.output.Data(), <- errors; + err := <- errors; + return s.output.Data(), err; }