aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/race
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/race')
-rw-r--r--src/runtime/race/README15
-rw-r--r--src/runtime/race/output_test.go80
-rw-r--r--src/runtime/race/race.go2
-rw-r--r--src/runtime/race/race_darwin_amd64.sysobin449292 -> 451280 bytes
-rw-r--r--src/runtime/race/race_darwin_arm64.sysobin0 -> 438936 bytes
-rw-r--r--src/runtime/race/race_freebsd_amd64.sysobin579744 -> 583264 bytes
-rw-r--r--src/runtime/race/race_linux_amd64.sysobin521752 -> 525176 bytes
-rw-r--r--src/runtime/race/race_linux_arm64.sysobin500584 -> 505224 bytes
-rw-r--r--src/runtime/race/race_linux_ppc64le.sysobin623824 -> 624648 bytes
-rw-r--r--src/runtime/race/race_netbsd_amd64.sysobin602664 -> 609424 bytes
-rw-r--r--src/runtime/race/race_test.go4
-rw-r--r--src/runtime/race/race_windows_amd64.sysobin458427 -> 461185 bytes
-rw-r--r--src/runtime/race/testdata/atomic_test.go24
-rw-r--r--src/runtime/race/testdata/chan_test.go22
-rw-r--r--src/runtime/race/testdata/io_test.go3
-rw-r--r--src/runtime/race/testdata/sync_test.go2
16 files changed, 137 insertions, 15 deletions
diff --git a/src/runtime/race/README b/src/runtime/race/README
index 34485f0fb2..178ab94ab5 100644
--- a/src/runtime/race/README
+++ b/src/runtime/race/README
@@ -4,10 +4,11 @@ the LLVM project (https://github.com/llvm/llvm-project/tree/master/compiler-rt).
To update the .syso files use golang.org/x/build/cmd/racebuild.
-race_darwin_amd64.syso built with LLVM 3496d6e4bea9cb99cb382939b7e79a50a3b863a5 and Go 553e003414d3aa90cc39830ee22f08453d9f3408.
-race_freebsd_amd64.syso built with LLVM 3496d6e4bea9cb99cb382939b7e79a50a3b863a5 and Go 553e003414d3aa90cc39830ee22f08453d9f3408.
-race_linux_amd64.syso built with LLVM 6c75db8b4bc59eace18143ce086419d37da24746 and Go 7388956b76ce15a11346cebefcf6193db044caaf.
-race_linux_ppc64le.syso built with LLVM 6c75db8b4bc59eace18143ce086419d37da24746 and Go 7388956b76ce15a11346cebefcf6193db044caaf.
-race_netbsd_amd64.syso built with LLVM 3496d6e4bea9cb99cb382939b7e79a50a3b863a5 and Go 553e003414d3aa90cc39830ee22f08453d9f3408.
-race_windows_amd64.syso built with LLVM 3496d6e4bea9cb99cb382939b7e79a50a3b863a5 and Go 553e003414d3aa90cc39830ee22f08453d9f3408.
-race_linux_arm64.syso built with LLVM 6c75db8b4bc59eace18143ce086419d37da24746 and Go 7388956b76ce15a11346cebefcf6193db044caaf.
+race_darwin_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b.
+race_freebsd_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b.
+race_linux_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b.
+race_linux_ppc64le.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b.
+race_netbsd_amd64.syso built with LLVM 89f7ccea6f6488c443655880229c54db1f180153 and Go f62d3202bf9dbb3a00ad2a2c63ff4fa4188c5d3b.
+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.
diff --git a/src/runtime/race/output_test.go b/src/runtime/race/output_test.go
index d3e7762175..986667332f 100644
--- a/src/runtime/race/output_test.go
+++ b/src/runtime/race/output_test.go
@@ -8,7 +8,6 @@ package race_test
import (
"internal/testenv"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -19,7 +18,7 @@ import (
)
func TestOutput(t *testing.T) {
- pkgdir, err := ioutil.TempDir("", "go-build-race-output")
+ pkgdir, err := os.MkdirTemp("", "go-build-race-output")
if err != nil {
t.Fatal(err)
}
@@ -34,7 +33,7 @@ func TestOutput(t *testing.T) {
t.Logf("test %v runs only on %v, skipping: ", test.name, test.goos)
continue
}
- dir, err := ioutil.TempDir("", "go-build")
+ dir, err := os.MkdirTemp("", "go-build")
if err != nil {
t.Fatalf("failed to create temp directory: %v", err)
}
@@ -309,7 +308,7 @@ Read at 0x[0-9,a-f]+ by main goroutine:
Previous write at 0x[0-9,a-f]+ by goroutine [0-9]:
main\.goCallback\(\)
.*/main\.go:27 \+0x[0-9,a-f]+
- main._cgoexpwrap_[0-9a-z]+_goCallback\(\)
+ _cgoexp_[0-9a-z]+_goCallback\(\)
.*_cgo_gotypes\.go:[0-9]+ \+0x[0-9,a-f]+
Goroutine [0-9] \(running\) created at:
@@ -338,4 +337,77 @@ func TestPass(t *testing.T) {
--- FAIL: TestFail \(0...s\)
.*testing.go:.*: race detected during execution of test
FAIL`},
+ {"mutex", "run", "", "atexit_sleep_ms=0", `
+package main
+import (
+ "sync"
+ "fmt"
+)
+func main() {
+ c := make(chan bool, 1)
+ threads := 1
+ iterations := 20000
+ data := 0
+ var wg sync.WaitGroup
+ for i := 0; i < threads; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for i := 0; i < iterations; i++ {
+ c <- true
+ data += 1
+ <- c
+ }
+ }()
+ }
+ for i := 0; i < iterations; i++ {
+ c <- true
+ data += 1
+ <- c
+ }
+ wg.Wait()
+ if (data == iterations*(threads+1)) { fmt.Println("pass") }
+}`, `pass`},
+ // Test for https://github.com/golang/go/issues/37355
+ {"chanmm", "run", "", "atexit_sleep_ms=0", `
+package main
+import (
+ "sync"
+ "time"
+)
+func main() {
+ c := make(chan bool, 1)
+ var data uint64
+ var wg sync.WaitGroup
+ wg.Add(2)
+ c <- true
+ go func() {
+ defer wg.Done()
+ c <- true
+ }()
+ go func() {
+ defer wg.Done()
+ time.Sleep(time.Second)
+ <-c
+ data = 2
+ }()
+ data = 1
+ <-c
+ wg.Wait()
+ _ = data
+}
+`, `==================
+WARNING: DATA RACE
+Write at 0x[0-9,a-f]+ by goroutine [0-9]:
+ main\.main\.func2\(\)
+ .*/main\.go:21 \+0x[0-9,a-f]+
+
+Previous write at 0x[0-9,a-f]+ by main goroutine:
+ main\.main\(\)
+ .*/main\.go:23 \+0x[0-9,a-f]+
+
+Goroutine [0-9] \(running\) created at:
+ main\.main\(\)
+ .*/main.go:[0-9]+ \+0x[0-9,a-f]+
+==================`},
}
diff --git a/src/runtime/race/race.go b/src/runtime/race/race.go
index c894de5f72..d6a14b79e7 100644
--- a/src/runtime/race/race.go
+++ b/src/runtime/race/race.go
@@ -2,7 +2,7 @@
// 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
+// +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
package race
diff --git a/src/runtime/race/race_darwin_amd64.syso b/src/runtime/race/race_darwin_amd64.syso
index d03a593f5a..3f95ecc8ee 100644
--- a/src/runtime/race/race_darwin_amd64.syso
+++ b/src/runtime/race/race_darwin_amd64.syso
Binary files differ
diff --git a/src/runtime/race/race_darwin_arm64.syso b/src/runtime/race/race_darwin_arm64.syso
new file mode 100644
index 0000000000..f6eaa62ae3
--- /dev/null
+++ b/src/runtime/race/race_darwin_arm64.syso
Binary files differ
diff --git a/src/runtime/race/race_freebsd_amd64.syso b/src/runtime/race/race_freebsd_amd64.syso
index 573591c56f..2a5b46f4ce 100644
--- a/src/runtime/race/race_freebsd_amd64.syso
+++ b/src/runtime/race/race_freebsd_amd64.syso
Binary files differ
diff --git a/src/runtime/race/race_linux_amd64.syso b/src/runtime/race/race_linux_amd64.syso
index d31f85df56..e00398c964 100644
--- a/src/runtime/race/race_linux_amd64.syso
+++ b/src/runtime/race/race_linux_amd64.syso
Binary files differ
diff --git a/src/runtime/race/race_linux_arm64.syso b/src/runtime/race/race_linux_arm64.syso
index 7c74171b0f..9dae738700 100644
--- a/src/runtime/race/race_linux_arm64.syso
+++ b/src/runtime/race/race_linux_arm64.syso
Binary files differ
diff --git a/src/runtime/race/race_linux_ppc64le.syso b/src/runtime/race/race_linux_ppc64le.syso
index a3c72bec55..b562656d56 100644
--- a/src/runtime/race/race_linux_ppc64le.syso
+++ b/src/runtime/race/race_linux_ppc64le.syso
Binary files differ
diff --git a/src/runtime/race/race_netbsd_amd64.syso b/src/runtime/race/race_netbsd_amd64.syso
index 54e276bcff..11af16f046 100644
--- a/src/runtime/race/race_netbsd_amd64.syso
+++ b/src/runtime/race/race_netbsd_amd64.syso
Binary files differ
diff --git a/src/runtime/race/race_test.go b/src/runtime/race/race_test.go
index a0b8531b42..d433af6bd0 100644
--- a/src/runtime/race/race_test.go
+++ b/src/runtime/race/race_test.go
@@ -177,6 +177,10 @@ func runTests(t *testing.T) ([]byte, error) {
)
// There are races: we expect tests to fail and the exit code to be non-zero.
out, _ := cmd.CombinedOutput()
+ if bytes.Contains(out, []byte("fatal error:")) {
+ // But don't expect runtime to crash.
+ return out, fmt.Errorf("runtime fatal error")
+ }
return out, nil
}
diff --git a/src/runtime/race/race_windows_amd64.syso b/src/runtime/race/race_windows_amd64.syso
index abaf42649f..9fbf9b4391 100644
--- a/src/runtime/race/race_windows_amd64.syso
+++ b/src/runtime/race/race_windows_amd64.syso
Binary files differ
diff --git a/src/runtime/race/testdata/atomic_test.go b/src/runtime/race/testdata/atomic_test.go
index 769c8d7398..4ce72604a4 100644
--- a/src/runtime/race/testdata/atomic_test.go
+++ b/src/runtime/race/testdata/atomic_test.go
@@ -299,3 +299,27 @@ func TestNoRaceAtomicCrash(t *testing.T) {
}()
atomic.AddInt32(nilptr, 1)
}
+
+func TestNoRaceDeferAtomicStore(t *testing.T) {
+ // Test that when an atomic function is deferred directly, the
+ // GC scans it correctly. See issue 42599.
+ type foo struct {
+ bar int64
+ }
+
+ var doFork func(f *foo, depth int)
+ doFork = func(f *foo, depth int) {
+ atomic.StoreInt64(&f.bar, 1)
+ defer atomic.StoreInt64(&f.bar, 0)
+ if depth > 0 {
+ for i := 0; i < 2; i++ {
+ f2 := &foo{}
+ go doFork(f2, depth-1)
+ }
+ }
+ runtime.GC()
+ }
+
+ f := &foo{}
+ doFork(f, 11)
+}
diff --git a/src/runtime/race/testdata/chan_test.go b/src/runtime/race/testdata/chan_test.go
index 3e57b8221c..e39ad4f99c 100644
--- a/src/runtime/race/testdata/chan_test.go
+++ b/src/runtime/race/testdata/chan_test.go
@@ -763,3 +763,25 @@ func TestNoRaceCloseHappensBeforeRead(t *testing.T) {
<-read
}
}
+
+// Test that we call the proper race detector function when c.elemsize==0.
+// See https://github.com/golang/go/issues/42598
+func TestNoRaceElemetSize0(t *testing.T) {
+ var x, y int
+ var c = make(chan struct{}, 2)
+ c <- struct{}{}
+ c <- struct{}{}
+ go func() {
+ x += 1
+ <-c
+ }()
+ go func() {
+ y += 1
+ <-c
+ }()
+ time.Sleep(10 * time.Millisecond)
+ c <- struct{}{}
+ c <- struct{}{}
+ x += 1
+ y += 1
+}
diff --git a/src/runtime/race/testdata/io_test.go b/src/runtime/race/testdata/io_test.go
index 30a121bee4..c5055f7837 100644
--- a/src/runtime/race/testdata/io_test.go
+++ b/src/runtime/race/testdata/io_test.go
@@ -6,7 +6,6 @@ package race_test
import (
"fmt"
- "io/ioutil"
"net"
"net/http"
"os"
@@ -18,7 +17,7 @@ import (
func TestNoRaceIOFile(t *testing.T) {
x := 0
- path, _ := ioutil.TempDir("", "race_test")
+ path, _ := os.MkdirTemp("", "race_test")
fname := filepath.Join(path, "data")
go func() {
x = 42
diff --git a/src/runtime/race/testdata/sync_test.go b/src/runtime/race/testdata/sync_test.go
index 2b2d95d76b..b5fcd6c4cf 100644
--- a/src/runtime/race/testdata/sync_test.go
+++ b/src/runtime/race/testdata/sync_test.go
@@ -126,11 +126,11 @@ func TestNoRaceAfterFunc1(t *testing.T) {
func TestNoRaceAfterFunc2(t *testing.T) {
var x int
+ _ = x
timer := time.AfterFunc(10, func() {
x = 1
})
defer timer.Stop()
- _ = x
}
func TestNoRaceAfterFunc3(t *testing.T) {