aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/race
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2021-05-12 19:23:21 +0200
committerFilippo Valsorda <filippo@golang.org>2021-05-13 12:59:22 -0400
commited1f812cefc3ece4b21241ba4cba0272cd2484ed (patch)
tree2e336c94eb9797488234c0cb86b123c1c5f2932b /src/runtime/race
parentad1b6f3ee00ce2592503efec7a9793c4786f6274 (diff)
parent9d0819b27ca248f9949e7cf6bf7cb9fe7cf574e8 (diff)
downloadgo-ed1f812cefc3ece4b21241ba4cba0272cd2484ed.tar.xz
[dev.boringcrypto] all: merge commit 9d0819b27c (CL 314609) into dev.boringcrypto
There used to be two BoringCrypto-specific behaviors related to cipher suites in crypto/tls: 1. in FIPS-only mode, only a restricted set of AES ciphers is allowed 2. NOT in FIPS-only mode, AES would be prioritized over ChaCha20 even if AES hardware was not available The motivation of (2) is unclear, and BoringSSL doesn't have equivalent logic. This merge drops (2), and keeps (1). Note that the list of FIPS-only ciphers does not have priority semantics anymore, but the default logic still sorts them the same way as they used to be. Change-Id: I50544011085cfa2b087f323aebf5338c0bd2dd33
Diffstat (limited to 'src/runtime/race')
-rw-r--r--src/runtime/race/README3
-rw-r--r--src/runtime/race/output_test.go45
-rw-r--r--src/runtime/race/race.go3
-rw-r--r--src/runtime/race/race_linux_test.go1
-rw-r--r--src/runtime/race/race_openbsd_amd64.sysobin0 -> 688784 bytes
-rw-r--r--src/runtime/race/race_test.go1
-rw-r--r--src/runtime/race/race_unix_test.go1
-rw-r--r--src/runtime/race/race_windows_test.go1
-rw-r--r--src/runtime/race/sched_test.go1
-rw-r--r--src/runtime/race/syso_test.go1
-rw-r--r--src/runtime/race/testdata/io_test.go2
-rw-r--r--src/runtime/race/testdata/mutex_test.go9
-rw-r--r--src/runtime/race/timer_test.go1
13 files changed, 41 insertions, 28 deletions
diff --git a/src/runtime/race/README b/src/runtime/race/README
index 178ab94ab5..3b188a0361 100644
--- a/src/runtime/race/README
+++ b/src/runtime/race/README
@@ -1,6 +1,6 @@
runtime/race package contains the data race detector runtime library.
It is based on ThreadSanitizer race detector, that is currently a part of
-the LLVM project (https://github.com/llvm/llvm-project/tree/master/compiler-rt).
+the LLVM project (https://github.com/llvm/llvm-project/tree/main/compiler-rt).
To update the .syso files use golang.org/x/build/cmd/racebuild.
@@ -12,3 +12,4 @@ race_netbsd_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153
race_windows_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b.
race_linux_arm64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b.
race_darwin_arm64.syso built with LLVM 00da38ce2d36c07f12c287dc515d37bb7bc410e9 and Go fe70a3a0fd31441bcbb9932ecab11a6083cf2119.
+race_openbsd_amd64.syso built with LLVM fcf6ae2f070eba73074b6ec8d8281e54d29dbeeb and Go 8f2db14cd35bbd674cb2988a508306de6655e425.
diff --git a/src/runtime/race/output_test.go b/src/runtime/race/output_test.go
index 17dc32013f..99052071d0 100644
--- a/src/runtime/race/output_test.go
+++ b/src/runtime/race/output_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build race
// +build race
package race_test
@@ -19,11 +20,7 @@ import (
)
func TestOutput(t *testing.T) {
- pkgdir, err := os.MkdirTemp("", "go-build-race-output")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(pkgdir)
+ pkgdir := t.TempDir()
out, err := exec.Command(testenv.GoToolPath(t), "install", "-race", "-pkgdir="+pkgdir, "testing").CombinedOutput()
if err != nil {
t.Fatalf("go install -race: %v\n%s", err, out)
@@ -34,11 +31,7 @@ func TestOutput(t *testing.T) {
t.Logf("test %v runs only on %v, skipping: ", test.name, test.goos)
continue
}
- dir, err := os.MkdirTemp("", "go-build")
- if err != nil {
- t.Fatalf("failed to create temp directory: %v", err)
- }
- defer os.RemoveAll(dir)
+ dir := t.TempDir()
source := "main.go"
if test.run == "test" {
source = "main_test.go"
@@ -105,6 +98,8 @@ var tests = []struct {
{"simple", "run", "", "atexit_sleep_ms=0", `
package main
import "time"
+var xptr *int
+var donechan chan bool
func main() {
done := make(chan bool)
x := 0
@@ -116,32 +111,34 @@ func store(x *int, v int) {
*x = v
}
func startRacer(x *int, done chan bool) {
- go racer(x, done)
+ xptr = x
+ donechan = done
+ go racer()
}
-func racer(x *int, done chan bool) {
+func racer() {
time.Sleep(10*time.Millisecond)
- store(x, 42)
- done <- true
+ store(xptr, 42)
+ donechan <- true
}
`, []string{`==================
WARNING: DATA RACE
Write at 0x[0-9,a-f]+ by goroutine [0-9]:
main\.store\(\)
- .+/main\.go:12 \+0x[0-9,a-f]+
+ .+/main\.go:14 \+0x[0-9,a-f]+
main\.racer\(\)
- .+/main\.go:19 \+0x[0-9,a-f]+
+ .+/main\.go:23 \+0x[0-9,a-f]+
Previous write at 0x[0-9,a-f]+ by main goroutine:
main\.store\(\)
- .+/main\.go:12 \+0x[0-9,a-f]+
+ .+/main\.go:14 \+0x[0-9,a-f]+
main\.main\(\)
- .+/main\.go:8 \+0x[0-9,a-f]+
+ .+/main\.go:10 \+0x[0-9,a-f]+
Goroutine [0-9] \(running\) created at:
main\.startRacer\(\)
- .+/main\.go:15 \+0x[0-9,a-f]+
+ .+/main\.go:19 \+0x[0-9,a-f]+
main\.main\(\)
- .+/main\.go:7 \+0x[0-9,a-f]+
+ .+/main\.go:9 \+0x[0-9,a-f]+
==================
Found 1 data race\(s\)
exit status 66
@@ -238,15 +235,15 @@ func main() {
package main
var x int
-
+var c chan int
func main() {
- c := make(chan int)
- go f(c)
+ c = make(chan int)
+ go f()
x = 1
<-c
}
-func f(c chan int) {
+func f() {
g(c)
}
diff --git a/src/runtime/race/race.go b/src/runtime/race/race.go
index d6a14b79e7..84050e8771 100644
--- a/src/runtime/race/race.go
+++ b/src/runtime/race/race.go
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,windows,amd64 race,linux,ppc64le race,linux,arm64 race,darwin,arm64
+//go:build (race && linux && amd64) || (race && freebsd && amd64) || (race && netbsd && amd64) || (race && darwin && amd64) || (race && windows && amd64) || (race && linux && ppc64le) || (race && linux && arm64) || (race && darwin && arm64) || (race && openbsd && amd64)
+// +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,windows,amd64 race,linux,ppc64le race,linux,arm64 race,darwin,arm64 race,openbsd,amd64
package race
diff --git a/src/runtime/race/race_linux_test.go b/src/runtime/race/race_linux_test.go
index c00ce4d3df..9c0d48d6bd 100644
--- a/src/runtime/race/race_linux_test.go
+++ b/src/runtime/race/race_linux_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build linux && race
// +build linux,race
package race_test
diff --git a/src/runtime/race/race_openbsd_amd64.syso b/src/runtime/race/race_openbsd_amd64.syso
new file mode 100644
index 0000000000..9fefd87ec6
--- /dev/null
+++ b/src/runtime/race/race_openbsd_amd64.syso
Binary files differ
diff --git a/src/runtime/race/race_test.go b/src/runtime/race/race_test.go
index d433af6bd0..8c880b8570 100644
--- a/src/runtime/race/race_test.go
+++ b/src/runtime/race/race_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build race
// +build race
// This program is used to verify the race detector
diff --git a/src/runtime/race/race_unix_test.go b/src/runtime/race/race_unix_test.go
index 84f0acece6..acd6e47f98 100644
--- a/src/runtime/race/race_unix_test.go
+++ b/src/runtime/race/race_unix_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build race && (darwin || freebsd || linux)
// +build race
// +build darwin freebsd linux
diff --git a/src/runtime/race/race_windows_test.go b/src/runtime/race/race_windows_test.go
index 307a1ea6c0..e490d766dd 100644
--- a/src/runtime/race/race_windows_test.go
+++ b/src/runtime/race/race_windows_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build windows && race
// +build windows,race
package race_test
diff --git a/src/runtime/race/sched_test.go b/src/runtime/race/sched_test.go
index d6bb323cde..e904ebd20d 100644
--- a/src/runtime/race/sched_test.go
+++ b/src/runtime/race/sched_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build race
// +build race
package race_test
diff --git a/src/runtime/race/syso_test.go b/src/runtime/race/syso_test.go
index db846c5d2a..cbce5a8f18 100644
--- a/src/runtime/race/syso_test.go
+++ b/src/runtime/race/syso_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !android && !js && !ppc64le
// +build !android,!js,!ppc64le
// Note: we don't run on Android or ppc64 because if there is any non-race test
diff --git a/src/runtime/race/testdata/io_test.go b/src/runtime/race/testdata/io_test.go
index c5055f7837..3303cb0717 100644
--- a/src/runtime/race/testdata/io_test.go
+++ b/src/runtime/race/testdata/io_test.go
@@ -17,7 +17,7 @@ import (
func TestNoRaceIOFile(t *testing.T) {
x := 0
- path, _ := os.MkdirTemp("", "race_test")
+ path := t.TempDir()
fname := filepath.Join(path, "data")
go func() {
x = 42
diff --git a/src/runtime/race/testdata/mutex_test.go b/src/runtime/race/testdata/mutex_test.go
index cbed2d370c..9dbed9a2c9 100644
--- a/src/runtime/race/testdata/mutex_test.go
+++ b/src/runtime/race/testdata/mutex_test.go
@@ -78,16 +78,23 @@ func TestNoRaceMutexPureHappensBefore(t *testing.T) {
var mu sync.Mutex
var x int16 = 0
_ = x
+ written := false
ch := make(chan bool, 2)
go func() {
x = 1
mu.Lock()
+ written = true
mu.Unlock()
ch <- true
}()
go func() {
- <-time.After(1e5)
+ time.Sleep(100 * time.Microsecond)
mu.Lock()
+ for !written {
+ mu.Unlock()
+ time.Sleep(100 * time.Microsecond)
+ mu.Lock()
+ }
mu.Unlock()
x = 1
ch <- true
diff --git a/src/runtime/race/timer_test.go b/src/runtime/race/timer_test.go
index a6c34a8352..f11f8456a0 100644
--- a/src/runtime/race/timer_test.go
+++ b/src/runtime/race/timer_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build race
// +build race
package race_test