Issue #4709 RFC? refactor and reseed rand::Rng#4958
Merged
bors merged 5 commits intorust-lang:incomingfrom Feb 15, 2013
cpeterso:reseed-rng
Merged
Issue #4709 RFC? refactor and reseed rand::Rng#4958bors merged 5 commits intorust-lang:incomingfrom cpeterso:reseed-rng
bors merged 5 commits intorust-lang:incomingfrom
cpeterso:reseed-rng
Conversation
Contributor
Author
|
btw, most of this code could be deleted if the |
Contributor
|
I concur that much of this stuff should move into rust at some point; but this is a helpful short-term fix for misbehavior and I greatly appreciate it! |
bors
added a commit
that referenced
this pull request
Feb 15, 2013
For Issue #4709: **c531506 rt: rand.rs expects `rust_next()` to return `uint32_t`, not `size_t`** rand.rs expects `rustrt::rand_next()` to return `u32`, but the `rand_next()` C function returns `size_t`: https://github.com/mozilla/rust/blob/ca71c6ec5bb8106121cbe33eec5a6a9ca7786039/src/libcore/rand.rs#L34 **f4320b6 move isaac RNG utility functions to new rust_rng.cpp file** **665e900 encapsulate isaac RNG in `rust_rng` struct** Move isaac's `randctx` into a `rust_rng` struct to make names similar to `rand::Rng` function names and prepare for auto-reseeding in the next commit. **9a78dc9 reseed `rust_rng` after generating 32KB** Precedents from other languages: * Haskell's `GenAutoReseed` generator reseeds itself after generating 32KB: http://hackage.haskell.org/packages/archive/DRBG/0.1.2/doc/html/Crypto-Random-DRBG.html#t:GenAutoReseed * Go's RNG reseeds itself after generating 1MB: https://code.google.com/p/go/source/browse/src/pkg/crypto/rand/rand_unix.go?name=go1.0.3#94 **9a76d71 don't deplete RNG entropy when there is only one runnable task** `rust_sched_loop::schedule_task()` unnecessarily calls `isaac_rand()` for the common case when there is only 1 runnable task, thus depleting RNG entropy and incurring unnecessary overhead.
5 tasks
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
May 2, 2020
Fix bad `explicit_into_iter_loop` suggestion Fixes rust-lang#4958 changelog: Fix bad `explicit_into_iter_loop` suggestion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For Issue #4709:
c531506 rt: rand.rs expects
rust_next()to returnuint32_t, notsize_trand.rs expects
rustrt::rand_next()to returnu32, but therand_next()C function returnssize_t: https://github.com/mozilla/rust/blob/ca71c6ec5bb8106121cbe33eec5a6a9ca7786039/src/libcore/rand.rs#L34f4320b6 move isaac RNG utility functions to new rust_rng.cpp file
665e900 encapsulate isaac RNG in
rust_rngstructMove isaac's
randctxinto arust_rngstruct to make names similar torand::Rngfunction names and prepare for auto-reseeding in the next commit.9a78dc9 reseed
rust_rngafter generating 32KBPrecedents from other languages:
GenAutoReseedgenerator reseeds itself after generating 32KB: http://hackage.haskell.org/packages/archive/DRBG/0.1.2/doc/html/Crypto-Random-DRBG.html#t:GenAutoReseed9a76d71 don't deplete RNG entropy when there is only one runnable task
rust_sched_loop::schedule_task()unnecessarily callsisaac_rand()for the common case when there is only 1 runnable task, thus depleting RNG entropy and incurring unnecessary overhead.