-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
What version of Go are you using (go version
)?
# Both versions are affected: $ go version go version go1.11.2 linux/amd64 $ go version go version go1.11.4 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GOARCH="amd64" GOBIN="" GOCACHE="/home/yegortimoshenko/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/yegortimoshenko/.local/share/go:/nix/store/yh6p6ky7w2nfa64r3r7vhr5d5s1p87bk-go-1.11.2/share/go" GOPROXY="" GORACE="" GOROOT="/nix/store/yh6p6ky7w2nfa64r3r7vhr5d5s1p87bk-go-1.11.2/share/go" GOTMPDIR="" GOTOOLDIR="/nix/store/yh6p6ky7w2nfa64r3r7vhr5d5s1p87bk-go-1.11.2/share/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" 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=/run/user/1000/go-build002404125=/tmp/go-build -gno-record-gcc-switches"
What did you do?
https://play.golang.org/p/v9ajjMHKx5M
What did you expect to see?
Consistent output between invocations, across all platforms.
What did you see instead?
When I run this program built locally with go1.11.2 or go1.11.4, I'm sometimes getting 1810a846745d4bc329c923c76786416d75dbd711eb369a824ebcff3078d22519
, sometimes b2d4c5a6c6683cab81962ba61e71a2dec2869ce947078958413b686a0ca48c7f
.
When I run this program built locally with go1.10.3, I'm always getting 1810a846745d4bc329c923c76786416d75dbd711eb369a824ebcff3078d22519
.
When I run this program on play.golang.org, I'm always getting b2d4c5a6c6683cab81962ba61e71a2dec2869ce947078958413b686a0ca48c7f
.
Additional notes
Creating a wrapped Source
that locks and unlocks mutex on each Source.Int63()
call doesn't resolve the issue: https://play.golang.org/p/JgJ4kM3UjY8
This is not specific to PRNG implementation, either. When I replace math/rand
Source
PRNG with PCG RNG, the issue still persists.
Some invocations seem to consume more RNG values, as seen in this example: https://play.golang.org/p/W1bTSIb5FYD (always 426
on play.golang.org, always 206
on go1.10.3, 206
or 426
on go1.11.2 and go1.11.4).