Closed
Description
What version of Go are you using (go version
)?
go version go1.7.6 linux/amd64
go version go1.8.3 linux/amd64
go version go1.9.2 linux/amd64
go version go1.10 linux/amd64
go version devel +7974f0815e Mon Mar 19 21:51:23 2018 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/twmb/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/twmb/go"
GORACE=""
GOROOT="/home/twmb/go/go"
GOTMPDIR=""
GOTOOLDIR="/home/twmb/go/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build795784354=/tmp/go-build -gno-record-gcc-switches"
What did you do?
https://play.golang.org/p/7nPiZfCjbgq
What did you expect to see?
starting
done
What did you see instead?
starting
==================
WARNING: DATA RACE
Read at 0x00c420112c90 by goroutine 73:
net.(*netFD).dup()
/home/twmb/go/go/src/net/fd_unix.go:307 +0x40
net.(*conn).File()
/home/twmb/go/go/src/net/net.go:294 +0x4d
main.main.func2()
/home/twmb/testing/junk.go:29 +0x3a
Previous write at 0x00c420112c90 by goroutine 75:
internal/poll.(*FD).destroy()
/home/twmb/go/go/src/internal/poll/fd_unix.go:72 +0xa4
internal/poll.(*FD).decref()
/home/twmb/go/go/src/internal/poll/fd_mutex.go:211 +0x55
internal/poll.(*FD).Close()
/home/twmb/go/go/src/internal/poll/fd_unix.go:93 +0x6b
net.(*netFD).Close()
/home/twmb/go/go/src/net/fd_unix.go:184 +0x60
net.(*conn).Close()
/home/twmb/go/go/src/net/net.go:200 +0x60
net.(*TCPConn).Close()
<autogenerated>:1 +0x43
main.main.func3()
/home/twmb/testing/junk.go:35 +0x3e
Goroutine 73 (running) created at:
main.main()
/home/twmb/testing/junk.go:28 +0x13f
Goroutine 75 (finished) created at:
main.main()
/home/twmb/testing/junk.go:34 +0x16b
==================
==================
WARNING: DATA RACE
Read at 0x00c4204078af by goroutine 296:
internal/poll.(*FD).Close()
/home/twmb/go/go/src/internal/poll/fd_unix.go:99 +0x91
net.(*netFD).Close()
/home/twmb/go/go/src/net/fd_unix.go:184 +0x60
net.(*conn).Close()
/home/twmb/go/go/src/net/net.go:200 +0x60
net.(*TCPConn).Close()
<autogenerated>:1 +0x43
main.main.func3()
/home/twmb/testing/junk.go:35 +0x3e
Previous write at 0x00c4204078af by goroutine 263:
internal/poll.(*FD).SetBlocking()
/home/twmb/go/go/src/internal/poll/fd_unix.go:121 +0x8f
net.(*netFD).dup()
/home/twmb/go/go/src/net/fd_unix.go:316 +0x7d
net.(*conn).File()
/home/twmb/go/go/src/net/net.go:294 +0x4d
main.main.func2()
/home/twmb/testing/junk.go:29 +0x3a
Goroutine 296 (running) created at:
main.main()
/home/twmb/testing/junk.go:34 +0x16b
Goroutine 263 (running) created at:
main.main()
/home/twmb/testing/junk.go:28 +0x13f
==================
done
This is different from #24481 because one of the two races is present back in old versions of Go as well. The first (destroy + dup) is old. The second is likely from 0f3ab149ec4
.