Skip to content

net/http: An empty reply causes false race conditions (go1.3beta1+) #7856

Closed
@gopherbot

Description

@gopherbot

by travis.bischel:

What does 'go version' print?
go version devel +f8b50ad4cac4 Mon Apr 21 17:00:27 2014 -0700 + linux/amd64

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

This can be done with three files:
http://play.golang.org/p/bxMjv7H1cw
1. create server.go and `go run` it
2. create race.go and race_test.go in a different directory
3. go test -race

What happened?
$ go test -race
==================
WARNING: DATA RACE
Write by goroutine 6:
  strings.(*Reader).Read()
      /usr/local/go/src/pkg/strings/reader.go:32 +0x6f
  go.(*struct { *strings.Reader; io.Closer }).Read()
      /usr/local/go/src/pkg/net/http/chunked.go:1 +0x90
  net/http.(*bodyEOFSignal).Read()
      /usr/local/go/src/pkg/net/http/transport.go:1123 +0x278
  io/ioutil.devNull.ReadFrom()
      /usr/local/go/src/pkg/io/ioutil/ioutil.go:151 +0xda
  io.Copy()
      /usr/local/go/src/pkg/io/io.go:349 +0x156
  _/home/twmb/testing.request()
      /home/twmb/testing/race.go:16 +0x1aa

Previous write by goroutine 7:
  strings.(*Reader).Read()
      /usr/local/go/src/pkg/strings/reader.go:32 +0x6f
  go.(*struct { *strings.Reader; io.Closer }).Read()
      /usr/local/go/src/pkg/net/http/chunked.go:1 +0x90
  net/http.(*bodyEOFSignal).Read()
      /usr/local/go/src/pkg/net/http/transport.go:1123 +0x278
  io/ioutil.devNull.ReadFrom()
      /usr/local/go/src/pkg/io/ioutil/ioutil.go:151 +0xda
  io.Copy()
      /usr/local/go/src/pkg/io/io.go:349 +0x156
  _/home/twmb/testing.request()
      /home/twmb/testing/race.go:16 +0x1aa

Goroutine 6 (running) created at:
  _/home/twmb/testing.RaceTest()
      /home/twmb/testing/race.go:28 +0x94
  _/home/twmb/testing.TestRaceTest()
      /home/twmb/testing/race_test.go:8 +0x2b
  testing.tRunner()
      /usr/local/go/src/pkg/testing/testing.go:422 +0x10f

Goroutine 7 (finished) created at:
  _/home/twmb/testing.RaceTest()
      /home/twmb/testing/race.go:29 +0xc3
  _/home/twmb/testing.TestRaceTest()
      /home/twmb/testing/race_test.go:8 +0x2b
  testing.tRunner()
      /usr/local/go/src/pkg/testing/testing.go:422 +0x10f
==================
PASS
Found 1 data race(s)
exit status 66
FAIL    _/home/twmb/testing 1.028s

What should have happened instead?
No race condition.

Please provide any additional information below.
https://code.google.com/p/go/source/browse/src/pkg/net/http/response.go#233
https://code.google.com/p/go/source/browse/src/pkg/net/http/server.go#1977

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions