-
-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Remove automatic (delayed) reseed-on-fork #1379
Conversation
The only thing these achieve is a different error message
/// (every 64 kiB — see [`ReseedingRng`] documentation for details). | ||
/// | ||
/// `ThreadRng` is not automatically reseeded on fork. It is recommended to | ||
/// explicitly call [`ThreadRng::reseed`] immediately after a fork, for example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also could be worth to mention pthread_atfork
as a potential approach for doing this.
UPD: Further in the docs fork handlers are discussed and it's indeed not safe to mess with ThreadRng
state in fork handlers, including child ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, it might be okay: ThreadRng
methods should not be called at the time fork()
happens. But I don't see the need to advertise this beyond what is already said.
Nightly builds fail due to zerocopy (google/zerocopy#844). Probably a good idea to leave this PR open a little longer anyway in case anyone has concerns about the removal of automatic reseed-on-fork. |
No further comments, so I'll merge now. In case @tarcieri @briansmith or others have concerns, we still have the option to revert before 0.9. |
* benches/generators.rs: standardize thread_rng benchmarks * Remove cfgs from examples * Remove ReadRng * Add ThreadRng::reseed and doc to use * Remove fork protection from ReseedingRng; remove libc dep * Enable ReseedingRng without std * Move ReseedingRng up; remove module rand::rngs::adapter
See also #1362 #1377
CC @thomcc
Remove integrated fork protection.
Add
ThreadRng::reseed
and doc to suggest calling this on fork.Make
ReseedingRng::reseed
also clear the random value cache.