Skip to content

net: Race condition reading IPv4 packets using multiple goroutines #7341

@gopherbot

Description

@gopherbot

by jleimon:

Two goroutines each create a connection using net.Dial and periodically send ICMP Ping
request packets to two unique host IP addresses. Sometimes a goroutine will read an ICMP
Ping response initiated by the other goroutine. The attached example demonstrates the
behavior.


1. In the attached file 'bug.go', set the variables 'host0' and 'host1' to two unique IP
addresses that are up and that will respond to ICMP Ping request packets.
2. Build the program.
3. Run the program as root. (Max OS X, OpenBSD)
4. The program will send ping packets to the two hosts specified. When a ICMP Ping
response packet is received by a goroutine that did not initiate the request, a 'X' will
be displayed to standard output.

What is the expected output?

The expected output is a never ending stream of dots and no 'X's. (See below)

> sudo ./gonetworkbug 
Password:
Pinging 192.168.1.4...
Pinging 192.168.1.8...
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

What do you see instead?

> sudo ./gonetworkbug 
Password:
Pinging 192.168.1.4...
Pinging 192.168.1.8...
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................X....

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

Darwin Kernel Version 10.8.0

Which version are you using?  (run 'go version')

go version go1.2 darwin/amd64

Please provide any additional information below.

Bug also present on OpenBSD 5.1

Attachments:

  1. bug.go (2117 bytes)

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