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

Flush executables to disk after linkage #49432

Merged
merged 3 commits into from
Apr 5, 2018
Merged

Flush executables to disk after linkage #49432

merged 3 commits into from
Apr 5, 2018

Conversation

nabijaczleweli
Copy link
Contributor

A problem caused by not doing so in Chrome has been reported here.

File::sync_all() calls FlushFileBuffers() down the line, causing potentially unflushed buffers on high I/O-load systems to flush and preventing nasty non-reproducible bugs.

Closes #48545

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @michaelwoerister (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 27, 2018
@michaelwoerister
Copy link
Member

Thanks for the PR, @nabijaczleweli!

Could you please

  • check that the process exited successfully,
  • only do this on Windows,
  • and add a comment on why we are doing this?

@nabijaczleweli
Copy link
Contributor Author

Done

@michaelwoerister
Copy link
Member

Looks great now, thank you! Please squash the commits into one, then this should be good to go.

A problem caused by not doing so in Chrome has been reported here:
https://randomascii.wordpress.com/2018/02/25/compiler-bug-linker-bug-windows-kernel-bug/amp/

File::sync_all() calls FlushFileBuffers() down the line,
causing potentially unflushed buffers on high I/O-load systems to flush
and prevent nasty non-reproducible bugs.

The force-flush is only done on Windows and if the linker exited successfully

Closes #48545
@nabijaczleweli
Copy link
Contributor Author

Done

@ollie27
Copy link
Member

ollie27 commented Mar 29, 2018

This would also need to be done here:

match cmd.command().stdout(Stdio::piped()).stderr(Stdio::piped()).spawn() {
Ok(child) => return child.wait_with_output(),

Although I'm not convinced that it wouldn't be better to rely on the linker to perform this mitigation.

@nabijaczleweli
Copy link
Contributor Author

nabijaczleweli commented Mar 29, 2018

Done. As for "the linker" doing so – probably a good idea, but unreliable (henlo systems running 5-year-old ld).

@michaelwoerister
Copy link
Member

Thanks @nabijaczleweli and @ollie27!

@bors r+

@bors
Copy link
Contributor

bors commented Mar 30, 2018

📌 Commit 3787106 has been approved by michaelwoerister

@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 Mar 30, 2018
@bors
Copy link
Contributor

bors commented Mar 30, 2018

⌛ Testing commit 3787106 with merge 64f93f31b12940a6a4e083191fbaf5c1a479106a...

@bors
Copy link
Contributor

bors commented Mar 30, 2018

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 30, 2018
@nabijaczleweli
Copy link
Contributor Author

Error seems to've originated outside of this PR's scope 🤔

@ollie27
Copy link
Member

ollie27 commented Mar 31, 2018

FlushFileBuffers requires that the file is opened with write permissions but fs::File::open is read-only.

This should be enough and shouldn't require append(true) since we're not
explicitly writing anything so we're not flushing it so we've no risk of
overwriting it
@nabijaczleweli
Copy link
Contributor Author

I was aware of that logically, but it's slipped my fingers. Anyway, fixed by using OpenOptions::write(true).

@michaelwoerister
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 3, 2018

📌 Commit e1d3c47 has been approved by michaelwoerister

@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 Apr 3, 2018
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Apr 5, 2018
…rister

Flush executables to disk after linkage

A problem caused by not doing so in Chrome has been reported [here](https://randomascii.wordpress.com/2018/02/25/compiler-bug-linker-bug-windows-kernel-bug/amp/).

`File::sync_all()` calls `FlushFileBuffers()` down the line, causing potentially unflushed buffers on high I/O-load systems to flush and preventing nasty non-reproducible bugs.

Closes rust-lang#48545
kennytm added a commit to kennytm/rust that referenced this pull request Apr 5, 2018
…rister

Flush executables to disk after linkage

A problem caused by not doing so in Chrome has been reported [here](https://randomascii.wordpress.com/2018/02/25/compiler-bug-linker-bug-windows-kernel-bug/amp/).

`File::sync_all()` calls `FlushFileBuffers()` down the line, causing potentially unflushed buffers on high I/O-load systems to flush and preventing nasty non-reproducible bugs.

Closes rust-lang#48545
bors added a commit that referenced this pull request Apr 5, 2018
Rollup of 9 pull requests

Successful merges:

 - #48658 (Add a generic CAS loop to std::sync::Atomic*)
 - #49253 (Take the original extra-filename passed to a crate into account when resolving it as a dependency)
 - #49345 (RFC 2008: Finishing Touches)
 - #49432 (Flush executables to disk after linkage)
 - #49496 (Add more vec![... ; n] optimizations)
 - #49563 (add a dist builder to build rust-std components for the THUMB targets)
 - #49654 (Host compiler documentation: Include private items)
 - #49667 (Add more features to rust_2018_preview)
 - #49674 (ci: Remove x86_64-gnu-incremental builder)

Failed merges:
@bors bors merged commit e1d3c47 into rust-lang:master Apr 5, 2018
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.

5 participants