]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/race: treat map concurrent access detection as a race detector hit
authorKeith Randall <khr@golang.org>
Wed, 6 Nov 2024 21:53:02 +0000 (13:53 -0800)
committerKeith Randall <khr@golang.org>
Thu, 7 Nov 2024 15:14:49 +0000 (15:14 +0000)
Sometimes the runtime realizes there is a race before the race detector does.
Maybe that's a bug in the race detector? But we should probably handle it.

Update #70164
(Fixes? I'm not sure.)

Change-Id: Ie7e8bf2b06701368e0551b4a1aa40f6746bbddd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/626036
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/runtime/race/race_test.go

index 4fe61683eb02d7f624d8953b05342b9d66105d61..cbc90ea0bb6aafd9d7151b94fc986c72a8aade58 100644 (file)
@@ -107,6 +107,11 @@ func processLog(testName string, tsanLog []string) string {
                        gotRace = true
                        break
                }
+               if strings.Contains(s, "fatal error: concurrent map") {
+                       // Detected by the runtime, not the race detector.
+                       gotRace = true
+                       break
+               }
        }
 
        failing := strings.Contains(testName, "Failing")
@@ -177,8 +182,11 @@ 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.
+       fatals := bytes.Count(out, []byte("fatal error:"))
+       mapFatals := bytes.Count(out, []byte("fatal error: concurrent map"))
+       if fatals > mapFatals {
+               // But don't expect runtime to crash (other than
+               // in the map concurrent access detector).
                return out, fmt.Errorf("runtime fatal error")
        }
        return out, nil