-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
When running:
$ go test -race net/http
ThreadSanitizer says:
WARNING: DATA RACE
Write by goroutine 205:
bufio.(*Reader).Read()
src/pkg/bufio/bufio.go:152 +0x4b6
io.(*LimitedReader).Read()
src/pkg/io/io.go:406 +0x181
net/http.(*body).Read()
src/pkg/net/http/transfer.go:538 +0xd4
io/ioutil.devNull.ReadFrom()
src/pkg/io/ioutil/ioutil.go:138 +0x6f
io/ioutil.devNull.ReadFrom·i()
src/pkg/io/ioutil/ioutil.go:0 +0x52
io.Copy()
src/pkg/io/io.go:352 +0xc6
net/http.(*body).Close()
src/pkg/net/http/transfer.go:628 +0x170
net/http.(*bodyEOFSignal).Close()
src/pkg/net/http/transport.go:817 +0xb9
net/http_test.func·082()
src/pkg/net/http/transport_test.go:428 +0xb7
Previous write by goroutine 111:
bufio.(*Reader).Read()
src/pkg/bufio/bufio.go:152 +0x4b6
io.(*LimitedReader).Read()
src/pkg/io/io.go:406 +0x181
net/http.(*body).Read()
src/pkg/net/http/transfer.go:538 +0xd4
io/ioutil.devNull.ReadFrom()
src/pkg/io/ioutil/ioutil.go:138 +0x6f
io/ioutil.devNull.ReadFrom·i()
src/pkg/io/ioutil/ioutil.go:0 +0x52
io.Copy()
src/pkg/io/io.go:352 +0xc6
net/http.(*body).Close()
src/pkg/net/http/transfer.go:628 +0x170
net/http.(*bodyEOFSignal).Close()
src/pkg/net/http/transport.go:817 +0xb9
net/http_test.func·082()
src/pkg/net/http/transport_test.go:428 +0xb7
Goroutine 205 (running) created at:
net/http_test.TestStressSurpriseServerCloses()
src/pkg/net/http/transport_test.go:432 +0x369
testing.tRunner()
src/pkg/testing/testing.go:297 +0xc9
Goroutine 111 (running) created at:
net/http_test.TestStressSurpriseServerCloses()
src/pkg/net/http/transport_test.go:432 +0x369
testing.tRunner()
src/pkg/testing/testing.go:297 +0xc9
When devNull is used all goroutines write to the single blackHole slice. The race aside,
it has performance implications when several parallel goroutines write the same memory.