-
Notifications
You must be signed in to change notification settings - Fork 432
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
rand::rngs::SmallRng
returns the same output for different seeds for at least ARM hosts.
#1032
Comments
If you want a simple, robust solution, I'd suggest using What we're seeing here is that two very similar seeds result in very similar streams: #907. We're likely to replace But why are you using such a poor seed? Many simple RNGs struggle with seeds containing many zeros. This won't be an issue with ChaCha and in general with cryptographic RNGs, but is with many non-crypto RNGs. If you can't use |
I ported the code from another library; I wouldn't know a good seed from a poor one, nor how to use any of the Rust RNGs, really. I'll look into your suggestions. |
There's a thing called the Hamming weight: the number of bits which are one. When this count is close to zero or close to the total number of bits, many basic PRNGs perform poorly. (Of course there may be more reasons.) I might as well close this then. We already have an issue about replacing the algorithm. |
This also isn't a bug anyway. I didn't read the docs:
Going to the
Fair enough. Is the "last byte" Contrast to the
On 32-bit systems, that one particular bit in |
Problem: As part of testing rust cross-compilation on a variety of hosts, I've found that
rand::rngs::SmallRng
returns the same output for different seeds on aarmv7-unknown-linux-gnueabihf
host. I'm not sure if this applies to other ARM hosts, even of the same architecture version (I'm using an ASUS TinkerBoard in this example). Nor am I sure this applies to other architectures;x86_64
Windows and Linux seem fine.Quick solution: Compile on hosts besides
armv7-unknown-linux-gnueabihf
:).Details: Consider the following program, with the
small_rng
feature enabled. I've created a small repo for convenience:On
x86_64-unknown-linux-gnu
(and Windows for that matter), this small program returns two different random identifiers for different seeds, as expected:On the other hand, on an
armv7-unknown-linux-gnueabihf
host, the same random identifier is emitted twice for different seeds, before emitting a new identifier when a third seed is used:While my use case will eventually be replaced with a more robust solution, this currently prevents me from compiling my safe Rust embedded code on ARM hosts; safe interrupts rely on being unable to call interrupt functions in application code, and random identifiers is one way to do this.
The text was updated successfully, but these errors were encountered: