Skip to content

net/http: data race on Request.Method #3881

@dvyukov

Description

@dvyukov
On a proprietary test ThreadSanitizer says:

WARNING: DATA RACE at 0x00004020eb40
Write by goroutine 32:
  net/http.ReadResponse()
      src/pkg/net/http/response.go:110 +0x13c
  net/http.(*persistConn).readLoop()
      src/pkg/net/http/transport.go:564 +0x3f8
Previous read by goroutine 33:
  net/http.(*Request).write()
      src/pkg/net/http/request.go:321 +0xb81
  net/http.(*persistConn).writeLoop()
      src/pkg/net/http/transport.go:641 +0x231
Goroutine 32 (running) created at:
  net/http.(*Transport).getConn()
      src/pkg/net/http/transport.go:390 +0x769
  net/http.(*Transport).RoundTrip()
      src/pkg/net/http/transport.go:156 +0x31e
  net/http.send()
      src/pkg/net/http/client.go:141 +0x4e1
  net/http.(*Client).doFollowingRedirects()
      src/pkg/net/http/client.go:254 +0x8d8
  net/http.(*Client).Get()
      src/pkg/net/http/client.go:201 +0xc1
  net/http.Get()
      src/pkg/net/http/client.go:178 +0x55
  ...
  testing.tRunner()
      src/pkg/testing/testing.go:292 +0xb6
Goroutine 33 (running) created at:
  net/http.(*Transport).getConn()
      src/pkg/net/http/transport.go:391 +0x780
  net/http.(*Transport).RoundTrip()
      src/pkg/net/http/transport.go:156 +0x31e
  net/http.send()
      src/pkg/net/http/client.go:141 +0x4e1
  net/http.(*Client).doFollowingRedirects()
      src/pkg/net/http/client.go:254 +0x8d8
  net/http.(*Client).Get()
      src/pkg/net/http/client.go:201 +0xc1
  net/http.Get()
      src/pkg/net/http/client.go:178 +0x55
  ...
  testing.tRunner()
      src/pkg/testing/testing.go:292 +0xb6

During invocation of RoundTrip() string field Request.Method is concurrently read and
mutated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions