Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/tls: data race on error var #3862

Closed
dvyukov opened this issue Jul 25, 2012 · 2 comments
Closed

crypto/tls: data race on error var #3862

dvyukov opened this issue Jul 25, 2012 · 2 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented Jul 25, 2012

ThreadSanitizer says:

WARNING: DATA RACE at 0x0000401042d0
Read by goroutine 155:
  crypto/tls.(*Conn).error()
      src/pkg/crypto/tls/conn.go:73 +0x7e
  crypto/tls.(*Conn).Handshake()
      src/pkg/crypto/tls/conn.go:801 +0x6f
  crypto/tls.(*Conn).Read()
      src/pkg/crypto/tls/conn.go:754 +0x55
  bufio.(*Reader).fill()
      src/pkg/bufio/bufio.go:77 +0x187
  bufio.(*Reader).Peek()
      src/pkg/bufio/bufio.go:102 +0x118
  net/http.(*persistConn).readLoop()
      src/pkg/net/http/transport.go:539 +0x106
Previous write by goroutine 156:
  crypto/tls.(*Conn).Write()
      src/pkg/crypto/tls/conn.go:735 +0xdb
  bufio.(*Writer).Flush()
      src/pkg/bufio/bufio.go:418 +0x111
  net/http.(*Request).write()
      src/pkg/net/http/request.go:376 +0xbd4
  net/http.(*persistConn).writeLoop()
      src/pkg/net/http/transport.go:641 +0x1e4
Goroutine 155 (running) created at:
  net/http.(*Transport).getConn()
      src/pkg/net/http/transport.go:390 +0x7be
  net/http.(*Transport).RoundTrip()
      src/pkg/net/http/transport.go:156 +0x31e
  net/http.send()
      src/pkg/net/http/client.go:141 +0x47c
  net/http.(*Client).doFollowingRedirects()
      src/pkg/net/http/client.go:254 +0x941
  net/http.(*Client).Get()
      src/pkg/net/http/client.go:201 +0xc1
  net/http_test.func·044()
      src/pkg/net/http/serve_test.go:607 +0x26d
  net/http_test.func·065()
      src/pkg/net/http/serve_test.go:1201 +0x41
Goroutine 156 (running) created at:
  net/http.(*Transport).getConn()
      src/pkg/net/http/transport.go:391 +0x7d5
  net/http.(*Transport).RoundTrip()
      src/pkg/net/http/transport.go:156 +0x31e
  net/http.send()
      src/pkg/net/http/client.go:141 +0x47c
  net/http.(*Client).doFollowingRedirects()
      src/pkg/net/http/client.go:254 +0x941
  net/http.(*Client).Get()
      src/pkg/net/http/client.go:201 +0xc1
  net/http_test.func·044()
      src/pkg/net/http/serve_test.go:607 +0x26d
  net/http_test.func·065()
      src/pkg/net/http/serve_test.go:1201 +0x41

Races on interface values are harmful.

13810:c793f0042883 (Jul 24 tip)
@davecheney
Copy link
Contributor

Comment 1:

http://golang.org/cl/6497070
Tests pass but I need to load test and benchmark before proposing.

Labels changed: added priority-soon, removed priority-triage.

Owner changed to @davecheney.

Status changed to Accepted.

@davecheney
Copy link
Contributor

Comment 2:

This issue was closed by revision 67ee9a7.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
FiloSottile pushed a commit to FiloSottile/go that referenced this issue Oct 12, 2018
Fixes golang#3862.

There were many areas where conn.err was being accessed
outside the mutex. This proposal moves the err value to
an embedded struct to make it more obvious when the error
value is being accessed.

As there are no Benchmark tests in this package I cannot
feel confident of the impact of this additional locking,
although most will be uncontended.

R=dvyukov, agl
CC=golang-dev
https://golang.org/cl/6497070
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants