Skip to content

std: Update randomness implementation on Windows - #45370

Merged
bors merged 1 commit into
rust-lang:masterfrom
alexcrichton:update-windows-rand
Oct 21, 2017
Merged

bors merged 1 commit into
rust-lang:masterfrom
alexcrichton:update-windows-rand

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

This commit updates the OS random number generator on Windows to match the
upstream implementation in the rand crate. First proposed in
rust-random/rand#111 this implementation uses a "private" API of
RtlGenRandom. Despite the documentation indicating this is a private
function its widespread use in Chromium and Firefox as well as comments from
Microsoft internally indicates that it's highly unlikely to break.

Another motivation for switching this is to also attempt to make progress
on #44911. It may be the case that this function succeeds while the previous
implementation may fail in "weird" scenarios.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

This commit updates the OS random number generator on Windows to match the
upstream implementation in the `rand` crate. First proposed in
rust-random/rand#111 this implementation uses a "private" API of
`RtlGenRandom`. Despite the [documentation][dox] indicating this is a private
function its widespread use in Chromium and Firefox as well as [comments] from
Microsoft internally indicates that it's highly unlikely to break.

Another motivation for switching this is to also attempt to make progress
on rust-lang#44911. It may be the case that this function succeeds while the previous
implementation may fail in "weird" scenarios.

[dox]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694(v=vs.85).aspx
[comments]: rust-random/rand#111 (comment)
@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 18, 2017
exceptfds: *mut fd_set,
timeout: *const timeval) -> c_int;

#[link_name = "SystemFunction036"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh of course, SystemFunction036 😨

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

um\NTSecAPI.h
#define RtlGenRandom SystemFunction036

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment about why its used.

@sfackler

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Oct 18, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 55c0173 has been approved by sfackler

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 18, 2017
@bors

bors commented Oct 21, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 55c0173 with merge cc03782...

bors added a commit that referenced this pull request Oct 21, 2017
std: Update randomness implementation on Windows

This commit updates the OS random number generator on Windows to match the
upstream implementation in the `rand` crate. First proposed in
rust-random/rand#111 this implementation uses a "private" API of
`RtlGenRandom`. Despite the [documentation][dox] indicating this is a private
function its widespread use in Chromium and Firefox as well as [comments] from
Microsoft internally indicates that it's highly unlikely to break.

Another motivation for switching this is to also attempt to make progress
on #44911. It may be the case that this function succeeds while the previous
implementation may fail in "weird" scenarios.

[dox]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694(v=vs.85).aspx
[comments]: rust-random/rand#111 (comment)
@bors

bors commented Oct 21, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: sfackler
Pushing cc03782 to master...

@bors
bors merged commit 55c0173 into rust-lang:master Oct 21, 2017
@alexcrichton
alexcrichton deleted the update-windows-rand branch October 28, 2017 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants