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

Remove synchronization from Windows hashmap_random_keys #99371

Merged
merged 1 commit into from
Aug 3, 2022

Conversation

ChrisDenton
Copy link
Member

@ChrisDenton ChrisDenton commented Jul 17, 2022

Unfortunately using synchronization when generating hashmap keys can prevent it being used in DllMain.

Fixes #99341

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jul 17, 2022
@rustbot
Copy link
Collaborator

rustbot commented Jul 17, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive
Copy link
Collaborator

@ChrisDenton: no appropriate reviewer found, use r? to override

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 17, 2022
@ChrisDenton
Copy link
Member Author

ChrisDenton commented Jul 17, 2022

r? rust-lang/libs

@ChrisDenton ChrisDenton added the O-windows Operating system: Windows label Jul 17, 2022
@ChrisDenton
Copy link
Member Author

r? libs

@rust-highfive rust-highfive assigned thomcc and unassigned kennytm Aug 2, 2022
Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

I don't think it's that unfortunate. This is a lot cleaner anyway, and should be more efficient for cases that don't need the fallback.

In the future if we care about the cost of the extra syscall when BCryptGenRandom isn't supported, we could use an AtomicPtr to recover that1

That said, thiis seems more robust than that would be, and I suspect optimizing for the "no BCryptGenRandom" case doesn't matter.

Footnotes

  1. It would start out as preferred_rng, and get assigned to fallback_rng on error. This is similar to how we handle the flags we use for getrandom on linux.

@thomcc
Copy link
Member

thomcc commented Aug 2, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Aug 2, 2022

📌 Commit 46673bb has been approved by thomcc

It is now in the queue for this repository.

@bors bors 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 Aug 2, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 3, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#99371 (Remove synchronization from Windows `hashmap_random_keys`)
 - rust-lang#99614 (do not claim that transmute is like memcpy)
 - rust-lang#99738 (rustdoc: avoid inlining modules with duplicate names)
 - rust-lang#99800 (Fix futex module imports on wasm+atomics)
 - rust-lang#100079 (Replace `* -> vec` with `-> vec` in docs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5730f12 into rust-lang:master Aug 3, 2022
@rustbot rustbot added this to the 1.64.0 milestone Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows Operating system: Windows S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

std::collections::hash::map::new stuck on Windows 7
6 participants