Skip to content

runtime/race: unexpected race when Conn.Close used for synchronization #22132

@rogpeppe

Description

@rogpeppe

go version devel +a714470 Wed Sep 27 16:29:18 2017 +0000 linux/amd64

The following program reports a race even though the read of x
cannot happen in parallel with the assignment to x because
we wait for the connection to be closed before reading it.

https://play.golang.org/p/ufvoScCbSm

==================
WARNING: DATA RACE
Read at 0x00c42008a220 by main goroutine:
  main.main()
      /home/rog/src/tst.go:24 +0x288

Previous write at 0x00c42008a220 by goroutine 7:
  main.main.func1()
      /home/rog/src/tst.go:16 +0x7a

Goroutine 7 (finished) created at:
  main.main()
      /home/rog/src/tst.go:14 +0x16d
==================
2017/10/04 16:48:53 1
Found 1 data race(s)
exit status 66

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions