aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/race
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2020-02-15 19:23:07 -0800
committerKeith Randall <khr@golang.org>2020-02-25 23:41:03 +0000
commit089e482b3dd2026178c8ee5b90d9aadb6bf81239 (patch)
tree744166f39c5e64ddf74079b52d49294f4f00494c /src/runtime/race
parent0652c80e2afa14d62067be567c498c83a6485fd8 (diff)
downloadgo-089e482b3dd2026178c8ee5b90d9aadb6bf81239.tar.gz
go-089e482b3dd2026178c8ee5b90d9aadb6bf81239.zip
runtime: reorder race detector calls in slicecopy
In rare circumstances, this helps report a race which would otherwise go undetected. Fixes #36794 Change-Id: I8a3c9bd6fc34efa51516393f7ee72531c34fb073 Reviewed-on: https://go-review.googlesource.com/c/go/+/220685 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Diffstat (limited to 'src/runtime/race')
-rw-r--r--src/runtime/race/testdata/slice_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/runtime/race/testdata/slice_test.go b/src/runtime/race/testdata/slice_test.go
index 1ec52438ec..9009a9a4ea 100644
--- a/src/runtime/race/testdata/slice_test.go
+++ b/src/runtime/race/testdata/slice_test.go
@@ -5,6 +5,7 @@
package race_test
import (
+ "sync"
"testing"
)
@@ -590,3 +591,18 @@ func TestRaceSlice3(t *testing.T) {
_ = x[:1:i]
<-done
}
+
+var saved string
+
+func TestRaceSlice4(t *testing.T) {
+ // See issue 36794.
+ data := []byte("hello there")
+ var wg sync.WaitGroup
+ wg.Add(1)
+ go func() {
+ _ = string(data)
+ wg.Done()
+ }()
+ copy(data, data[2:])
+ wg.Wait()
+}