Skip to content

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

Closed
@hatoo

Description

@hatoo
Contributor

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.

Activity

added
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
O-macosOperating system: macOS
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
on Mar 20, 2020
RalfJung

RalfJung commented on Mar 20, 2020

@RalfJung
Member

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

added 2 commits that reference this issue on Mar 23, 2020

Rollup merge of rust-lang#70207 - hatoo:macos-getentropy, r=dtolnay

c43941a

Rollup merge of rust-lang#70207 - hatoo:macos-getentropy, r=dtolnay

675bdf6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.O-macosOperating system: macOST-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @RalfJung@hatoo@jonas-schievink

      Issue actions

        On macOS, try `getentropy()` before opening `/dev/urandom`? · Issue #70179 · rust-lang/rust