google / netstack

IPv4 and IPv6 userland network stack
Apache License 2.0
3.09k stars 279 forks source link

Data race between RemoveAddress() and WritePacket() #32

Closed windom closed 5 years ago

windom commented 5 years ago

Hi! I've just got the following data race. I'm using 94fb60fd787c1607c1742355a87725351ea4741b.

==================
WARNING: DATA RACE
Write at 0x00c00016cbf8 by goroutine 22:
  github.com/google/netstack/tcpip/stack.(*NIC).removePermanentAddressLocked()
      github.com/google/netstack/tcpip/stack/nic.go:472 +0xe6
  github.com/google/netstack/tcpip/stack.(*NIC).RemoveAddress()
      github.com/google/netstack/tcpip/stack/nic.go:482 +0x98
  github.com/google/netstack/tcpip/stack.(*Stack).RemoveAddress()
      github.com/google/netstack/tcpip/stack/stack.go:853 +0x109
.....

Previous read at 0x00c00016cbf8 by goroutine 114:
  github.com/google/netstack/tcpip/stack.(*Route).WritePacket()
      github.com/google/netstack/tcpip/stack/nic.go:769 +0x82
  github.com/google/netstack/tcpip/transport/tcp.sendTCP()
      github.com/google/netstack/tcpip/transport/tcp/connect.go:632 +0x5a5
  github.com/google/netstack/tcpip/transport/tcp.(*endpoint).sendRaw()
      github.com/google/netstack/tcpip/transport/tcp/connect.go:681 +0x27b
  github.com/google/netstack/tcpip/transport/tcp.(*endpoint).protocolMainLoop.func4()
      github.com/google/netstack/tcpip/transport/tcp/connect.go:727 +0x412
  github.com/google/netstack/tcpip/transport/tcp.(*endpoint).protocolMainLoop()
      github.com/google/netstack/tcpip/transport/tcp/connect.go:1069 +0x933
windom commented 5 years ago

Closed in favor of https://github.com/google/gvisor/issues/789