Skip to content

Commit

Permalink
Rollup merge of rust-lang#101014 - isikkema:fix-zmeta-stats-file-enco…
Browse files Browse the repository at this point in the history
…der-no-read-perms, r=isikkema

Fix -Zmeta-stats ICE by giving `FileEncoder` file read permissions

Fixes rust-lang#101001

As far as I can tell, rust-lang#101001 is caused because the file is being created with write-only permissions here: https://github.com/rust-lang/rust/blob/master/compiler/rustc_serialize/src/opaque.rs#L196

but it is trying to be read here: https://github.com/rust-lang/rust/blob/master/compiler/rustc_metadata/src/rmeta/encoder.rs#L780

This PR attempts to fix this by creating/opening the file with the same permissions as `File::create()` with the addition of read.
  • Loading branch information
notriddle authored Sep 20, 2022
2 parents 4136b59 + a2cb8a4 commit c1bffa5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_serialize/src/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ impl FileEncoder {
// shaves an instruction off those code paths (on x86 at least).
assert!(capacity <= usize::MAX - max_leb128_len());

let file = File::create(path)?;
// Create the file for reading and writing, because some encoders do both
// (e.g. the metadata encoder when -Zmeta-stats is enabled)
let file = File::options().read(true).write(true).create(true).truncate(true).open(path)?;

Ok(FileEncoder {
buf: Box::new_uninit_slice(capacity),
Expand Down

0 comments on commit c1bffa5

Please sign in to comment.