Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math/rand: problem with seed on windows/amd64 #8926

Closed
gopherbot opened this issue Oct 13, 2014 · 3 comments
Closed

math/rand: problem with seed on windows/amd64 #8926

gopherbot opened this issue Oct 13, 2014 · 3 comments

Comments

@gopherbot
Copy link

by kpashka:

> What does 'go version' print?

go version go1.3.3 windows/amd64

> What steps reproduce the problem?

http://play.golang.org/p/-JoqAkDZ16

> What happened?

First three numbers are same, fourth is different from three previous.

> What should have happened instead?

All numbers should (not always, but often) be different.

> Please provide any additional information below.

I know that Go Playground has special environment, but while running this test on
Windows 8.1 x64, I get the same incorrect results. My co-worker have ran this on Gentoo
(go version 1.3 linux/amd64) and got different numbers. I've also tried this using
windows/386 version and got incorrect results.
@cznic
Copy link
Contributor

cznic commented Oct 13, 2014

Comment 1:

Windows have poor time granularity, thus the first three calls may seed the PRNG with
the same number. You need to use some other source of entropy or seed the PRNG only
once, if possible.

@bradfitz
Copy link
Contributor

Comment 2:

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 3 by kpashka:

Ruby (and many other languages) use RSA cryptographic provider on Windows while seeding
RNG, e.g. http://www.ruby-doc.org/core-2.1.3/Random.html
Why this isn't possible in golang?

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants