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

On macOS, try getentropy() before opening /dev/urandom? #70179

Closed
hatoo opened this issue Mar 20, 2020 · 1 comment · Fixed by #70207
Closed

On macOS, try getentropy() before opening /dev/urandom? #70179

hatoo opened this issue Mar 20, 2020 · 1 comment · Fixed by #70207
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. O-macos Operating system: macOS T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@hatoo
Copy link
Contributor

hatoo commented Mar 20, 2020

Background

Hi, I'm developing a HTTP load generator called oha. The application often exceeds the number of open file limit and then, tokio runtime crashes because it tries to open /dev/urandom to generate random on macOS.

hatoo/oha#23

issue

On macOS, according to https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/rand.rs, fill_bytes always read /dev/urandom but opening /dev/urandom may fail because of the limit of the number of open files.
So it would be better to try getentropy like getrandom before reading /dev/urandom.

Thanks.

@jonas-schievink jonas-schievink added C-enhancement Category: An issue proposing an enhancement or a PR with one. O-macos Operating system: macOS T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Mar 20, 2020
@RalfJung
Copy link
Member

Miri would also like that, because it is easier to emulate. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. O-macos Operating system: macOS T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants