Skip to content

Commit

Permalink
Rollup merge of #101014 - isikkema:fix-zmeta-stats-file-encoder-no-re…
Browse files Browse the repository at this point in the history
…ad-perms, r=isikkema

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

Fixes #101001

As far as I can tell, #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 committed Sep 20, 2022
2 parents 14b27cf + a2cb8a4 commit 3f377d3
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 3f377d3

Please sign in to comment.