-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std::rand::reseeding: infinite recursion in fill_bytes() #10202
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
Comments
Oh that's not good! cc @huonw so he's aware, but if you would like to fix it (looks like the fix you have is legitimate), feel free to make the change, add some tests, and open a pull request! |
Oops! Second time I've done this with the RNG stuff! 😦 @telotortium tell me if you're not going to fix it, so I can whip up a patch. |
I'll fix it in an hour or two. |
bors
added a commit
that referenced
this issue
Nov 1, 2013
…w, r=huonw Fix the implementation of `std::rand::Rng::fill_bytes()` for `std::rand::reseeding::ReseedingRng` to call the `fill_bytes()` method of the underlying RNG rather than itself, which causes infinite recursion. Fixes #10202.
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Apr 3, 2025
Closes rust-lang#10202. This adds a new lint that checks for uses of the `.chars().enumerate()` position in a context where a byte index is required and suggests changing it to use `.char_indices()` instead. I'm planning to extend this lint to also detect uses of the position in iterator chains, e.g. `s.chars().enumerate().for_each(|(i, _)| s.split_at(i));`, but that's for another time ---------------- changelog: new lint: `chars_enumerate_for_byte_indices`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The example code for
std::rand::Rng::fill_bytes
fails due to a stack overflow:This is due to infinite recursion in the
ReseedingRng
trait (src/libstd/rand/reseeding.rs:72):self.fill_bytes(dest)
should beself.rng.fill_bytes(dest)
-- changing the line to that fixes the issue.The text was updated successfully, but these errors were encountered: