]> Cypherpunks repositories - gostls13.git/commit
runtime: fix false race report during tracing
authorDmitry Vyukov <dvyukov@google.com>
Tue, 3 Feb 2015 10:01:09 +0000 (13:01 +0300)
committerDmitry Vyukov <dvyukov@google.com>
Tue, 3 Feb 2015 15:41:41 +0000 (15:41 +0000)
commit4a45ac577f4739916b98f959015ce6a234327457
tree4fb221bc36c19a85662466a4e4469c3573510987
parentfc5baec37f65baf33a8b6777e576b85de62654ec
runtime: fix false race report during tracing

Currently race detector produces the following reports on pprof tests:

WARNING: DATA RACE
Read by goroutine 4:
  runtime/pprof_test.TestTraceStartStop()
      src/runtime/pprof/trace_test.go:38 +0x1da
  testing.tRunner()
      src/testing/testing.go:448 +0x13a

Previous write by goroutine 5:
  bytes.(*Buffer).grow()
      src/bytes/buffer.go:102 +0x190
  bytes.(*Buffer).Write()
      src/bytes/buffer.go:127 +0x75
  runtime/pprof.funcĀ·002()
      src/runtime/pprof/pprof.go:633 +0xae

Trace writer goroutine synchronizes with StopTrace
using trace.shutdownSema runtime semaphore.
But race detector does not see that synchronization
and so produces false reports.
Teach race detector about the synchronization.

Change-Id: I1219817325d4e16b423f29a0cbee94c929793881
Reviewed-on: https://go-review.googlesource.com/3746
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/trace.go