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

Avoid zeroing a 1kb stack buffer on every call to std::sys::windows::fill_utf16_buf #100729

Merged
merged 2 commits into from
Aug 20, 2022

Conversation

thomcc
Copy link
Member

@thomcc thomcc commented Aug 18, 2022

I've also tried to be slightly more careful about integer overflows, although in practice this is likely still not handled ideally.

r? @ChrisDenton

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

rustbot commented Aug 18, 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 rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 18, 2022
@thomcc
Copy link
Member Author

thomcc commented Aug 18, 2022

FYI: I wrote this on macOS, so probably don't r+ this without a try run first (it should be fine but for all I know I got some logic backwards or something).

@ChrisDenton
Copy link
Member

Well it doesn't look like there's anything in the try queue atm so we might as well use it for something...

@bors try

@bors
Copy link
Contributor

bors commented Aug 18, 2022

⌛ Trying commit f50f878 with merge d286d96ed7aad502865c5797ecb8c6c49237bb5f...

@Mark-Simulacrum
Copy link
Member

Try builds are Linux only dist builds without extra work so it probably won't show anything interesting.

@thomcc
Copy link
Member Author

thomcc commented Aug 18, 2022

Try builds are Linux only dist builds without extra work so it probably won't show anything interesting.

Nards. I was pretty sure I'd seen them run the windows CI tests before.

@ChrisDenton
Copy link
Member

Oh! That's annoying. If it helps I can test locally when I have a mo.

@Mark-Simulacrum
Copy link
Member

https://github.com/rust-lang/rust/blob/master/.github/workflows/ci.yml#L7 has the file you need to edit and rerun the expander to regenerate the actual configuration. Mostly just a matter of copying a windows job to the try: section.

@klensy
Copy link
Contributor

klensy commented Aug 18, 2022

There few similar places like that

const MAX_BUFFER_SIZE: usize = 8192;

fn write_valid_utf8_to_console(handle: c::HANDLE, utf8: &str) -> io::Result<usize> {
let mut utf16 = [0u16; MAX_BUFFER_SIZE / 2];
let mut len_utf16 = 0;

or

pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE: usize = 16 * 1024;

if info.dwFileAttributes & c::FILE_ATTRIBUTE_REPARSE_POINT != 0 {
let mut b = [0; c::MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
if let Ok((_, buf)) = self.reparse_point(&mut b) {

@bors
Copy link
Contributor

bors commented Aug 19, 2022

☀️ Try build successful - checks-actions
Build commit: d286d96ed7aad502865c5797ecb8c6c49237bb5f (d286d96ed7aad502865c5797ecb8c6c49237bb5f)

@ChrisDenton
Copy link
Member

Ok I've tested this locally and it looks great so let's get this merged.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 19, 2022

📌 Commit f50f878 has been approved by ChrisDenton

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 19, 2022
@ChrisDenton
Copy link
Member

@bors r- update comments

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 19, 2022
@ChrisDenton
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 19, 2022

📌 Commit d4cba61 has been approved by ChrisDenton

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 19, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 20, 2022
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#100186 (Mention `as_mut` alongside `as_ref` in borrowck error message)
 - rust-lang#100383 (Mitigate stale data reads on SGX platform)
 - rust-lang#100507 (suggest `once_cell::Lazy` for non-const statics)
 - rust-lang#100617 (Suggest the right help message for as_ref)
 - rust-lang#100667 (Migrate "invalid variable declaration" errors to SessionDiagnostic)
 - rust-lang#100709 (Migrate typeck's `used` expected symbol diagnostic to `SessionDiagnostic`)
 - rust-lang#100723 (Add the diagnostic translation lints to crates that don't emit them)
 - rust-lang#100729 (Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf`)
 - rust-lang#100750 (improved diagnostic for function defined with `def`, `fun`, `func`, or `function` instead of `fn`)
 - rust-lang#100763 (triagebot: Autolabel `A-rustdoc-json`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1e47e8a into rust-lang:master Aug 20, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 20, 2022
@thomcc thomcc deleted the less-initialized branch August 31, 2022 12:26
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 31, 2022
Avoid needless buffer zeroing in `std::sys::windows::fs`

Followup to rust-lang#101171 and rust-lang#101193. This finishes up avoiding buffer zeroing pointed out in rust-lang#100729 (comment) (thanks!)

r? `@ChrisDenton`
workingjubilee pushed a commit to tcdi/postgrestd that referenced this pull request Sep 15, 2022
Avoid needless buffer zeroing in `std::sys::windows::fs`

Followup to rust-lang/rust#101171 and rust-lang/rust#101193. This finishes up avoiding buffer zeroing pointed out in rust-lang/rust#100729 (comment) (thanks!)

r? `@ChrisDenton`
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. 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.

8 participants