Skip to content

net/http: data race in test #8483

Closed
Closed
@dvyukov

Description

@dvyukov
Freebsd-race builder says:

http://build.golang.org/log/08f6845ff56ba26e380d39f678275ed03072ba19

==================
WARNING: DATA RACE
Read by goroutine 61:
  sync.raceRead()
      /usr/local/go/src/pkg/sync/race.go:37 +0x35
  sync.(*WaitGroup).Add()
      /usr/local/go/src/pkg/sync/waitgroup.go:60 +0xbe
  net/http_test.func·189()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/transport_test.go:1074
+0xa6
  net/http.(*Transport).dial()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/transport.go:442
+0xcb
  net/http.(*Transport).dialConn()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/transport.go:496
+0xab
  net/http.func·022()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/transport.go:472
+0x8c

Previous write by goroutine 50:
  sync.raceWrite()
      /usr/local/go/src/pkg/sync/race.go:41 +0x35
  sync.(*WaitGroup).Wait()
      /usr/local/go/src/pkg/sync/waitgroup.go:122 +0x176
  net/http_test.TestTransportConcurrency()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/transport_test.go:1110
+0x6a3
  testing.tRunner()
      /usr/local/go/src/pkg/testing/testing.go:427 +0x10b

Goroutine 61 (running) created at:
  net/http.(*Transport).getConn()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/transport.go:474
+0x334
  net/http.(*Transport).RoundTrip()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/transport.go:201
+0x57e
  net/http.send()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/client.go:195
+0x626
  net/http.(*Client).send()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/client.go:118
+0x1ff
  net/http.(*Client).doFollowingRedirects()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/client.go:343
+0xd27
  net/http.(*Client).Get()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/client.go:275
+0xcd
  net/http_test.func·190()
      /usr/home/gopher/racer/work/freebsd-amd64-race-98c597959808/go/src/pkg/net/http/transport_test.go:1087
+0x188

Goroutine 50 (finished) created at:
  testing.RunTests()
      /usr/local/go/src/pkg/testing/testing.go:509 +0xb3e
  testing.Main()
      /usr/local/go/src/pkg/testing/testing.go:440 +0xa2
  main.main()
      net/http/_test/_testmain.go:479 +0xdc
==================

The test expects that Dial function will be called synchronously inside of client.Get.
But it is not. So the test does not wait for some of the dialers.

It could have been the root cause of:
https://golang.org/issue/6970
and some other spurious failures in net/http tests.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions