Skip to content

runtime/race: false positive in race detector #13096

@bradfitz

Description

@bradfitz

I'm seeing what appears to be a false positive in the race detector on Linux in the x/net/http2 tests:

=== RUN   TestServerWithCurl_LenientCipherSuites
==================
WARNING: DATA RACE
Write by goroutine 40:
  sync/atomic.StoreInt32()
      /home/bradfitz/go/src/runtime/race_amd64.s:215 +0xb
  golang.org/x/net/http2.testServerWithCurl.func2()
      /home/bradfitz/src/golang.org/x/net/http2/server_test.go:2228 +0x35
  golang.org/x/net/http2.ConfigureServer.func1()
      /home/bradfitz/src/golang.org/x/net/http2/server.go:191 +0x67
  net/http.(*conn).serve()
      /home/bradfitz/go/src/net/http/server.go:1323 +0xa95

Previous write by goroutine 31:
  golang.org/x/net/http2.testServerWithCurl()
      /home/bradfitz/src/golang.org/x/net/http2/server_test.go:2227 +0x343
  golang.org/x/net/http2.TestServerWithCurl_LenientCipherSuites()
      /home/bradfitz/src/golang.org/x/net/http2/server_test.go:2204 +0x33
  testing.tRunner()
      /home/bradfitz/go/src/testing/testing.go:456 +0xdc

Goroutine 40 (running) created at:
  net/http.(*Server).Serve()
      /home/bradfitz/go/src/net/http/server.go:1930 +0x533
  net/http/httptest.(*Server).goServe.func1()
      /home/bradfitz/go/src/net/http/httptest/server.go:215 +0xac

Goroutine 31 (running) created at:
  testing.RunTests()
      /home/bradfitz/go/src/testing/testing.go:561 +0xaaf
  testing.(*M).Run()
      /home/bradfitz/go/src/testing/testing.go:494 +0xe4
  main.main()
      golang.org/x/net/http2/_test/_testmain.go:272 +0x210
==================
--- PASS: TestServerWithCurl_LenientCipherSuites (0.78s)
        server_test.go:2230: Running test server for curl to hit at: https://127.0.0.1:37619
PASS

Except those two write lines, 2227 and 2228 are:

        var gotConn int32
        testHookOnConn = func() { atomic.StoreInt32(&gotConn, 1) }

Is the implicit zeroing of that variable counting as a write?

The only reference to that variable is at the end of the test:

        if atomic.LoadInt32(&gotConn) == 0 {
                t.Error("never saw an http2 connection")
        }

/cc @randall77

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions