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

-Zmeta-stats ICE: with thread 'rustc' panicked at 'called Result::unwrap() on an Err value: Os { code: 5, kind: PermissionDenied, message: "Access is denied." } #101001

Closed
klensy opened this issue Aug 25, 2022 · 4 comments · Fixed by #101014
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@klensy
Copy link
Contributor

klensy commented Aug 25, 2022

-Zmeta-stats started ICEing between nightly-2022-07-15 and nightly-2022-07-16, looking at diff c2f428d...23e21bd it's probably #96544, so @m-ysk ?

Code

cargo new --lib hello
cd hello
RUSTFLAGS="-Zmeta-stats" cargo build

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (e1b28cd2f 2022-08-19)
binary: rustc
commit-hash: e1b28cd2f16bd5b832183d7968cae3bb9213e78d
commit-date: 2022-08-19
host: x86_64-pc-windows-msvc
release: 1.65.0-nightly
LLVM version: 15.0.0

Error output

<output>
Backtrace

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 5, kind: PermissionDenied, message: "Access is denied." }', compiler\rustc_metadata\src\rmeta\encoder.rs:774:22
stack backtrace:
   0:     0x7fffb7e59982 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6af6f9f3a4c35d3a
   1:     0x7fffb7e94c8b - core::fmt::write::he3f07bcff4ed6652
   2:     0x7fffb7e4c48a - <std::io::IoSliceMut as core::fmt::Debug>::fmt::hf6257fd727ae80d5
   3:     0x7fffb7e5d254 - std::panicking::default_hook::hb6687dad6f786ea1
   4:     0x7fffb7e5ce8a - std::panicking::default_hook::hb6687dad6f786ea1
   5:     0x7fff99b8a9f2 - rustc_driver[1d98c199491bd8cd]::describe_lints
   6:     0x7fffb7e5dc52 - std::panicking::rust_panic_with_hook::hf223e88fa60de009
   7:     0x7fffb7e5d9dd - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h230f1146d8ddd341
   8:     0x7fffb7e5a67f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6af6f9f3a4c35d3a
   9:     0x7fffb7e5d6a0 - rust_begin_unwind
  10:     0x7fffb7ec9f35 - core::panicking::panic_fmt::he533ea2e8c7ab1f5
  11:     0x7fffb7eca0b3 - core::result::unwrap_failed::ha67da4e5ef765d0c
  12:     0x7fff99665e50 - <rustc_metadata[24368a714c5ae756]::rmeta::encoder::EncodeContext as rustc_type_ir[15febabf03c45dc7]::codec::TyEncoder>::predicate_shorthands
  13:     0x7fff980fc525 - rustc_metadata[24368a714c5ae756]::rmeta::encoder::encode_metadata
  14:     0x7fff980fdd6c - <rustc_metadata[24368a714c5ae756]::rmeta::encoder::EncodeContext as rustc_serialize[3bf25e14274047cb]::serialize::Encoder>::emit_raw_bytes
  15:     0x7fff980fba6e - rustc_metadata[24368a714c5ae756]::rmeta::encoder::encode_metadata
  16:     0x7fff980f4711 - rustc_metadata[24368a714c5ae756]::fs::encode_and_write_metadata
  17:     0x7fff974c3b0c - <rustc_interface[3b6d288906cb4b04]::passes::LintStoreExpandImpl as rustc_expand[4331ab26a72f6383]::base::LintStoreExpand>::pre_expansion_lint
  18:     0x7fff974b00dc - <rustc_interface[3b6d288906cb4b04]::queries::Queries>::ongoing_codegen
  19:     0x7fff97466c69 - <unknown>
  20:     0x7fff974630eb - <unknown>
  21:     0x7fff97486532 - <unknown>
  22:     0x7fff9749d727 - rustc_driver[1d98c199491bd8cd]::args::arg_expand_all
  23:     0x7fff97466449 - <unknown>
  24:     0x7fff9748cbed - <unknown>
  25:     0x7fffb7e6e41c - std::sys::windows::thread::Thread::new::h5a05fdb6284bcf7c
  26:     0x7ff800497034 - BaseThreadInitThunk
  27:     0x7ff802e22651 - RtlUserThreadStart

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.65.0-nightly (e1b28cd2f 2022-08-19) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -Z meta-stats

@klensy klensy added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 25, 2022
@isikkema
Copy link

isikkema commented Aug 25, 2022

Looks like file is created write-only here: https://github.com/rust-lang/rust/blob/master/compiler/rustc_serialize/src/opaque.rs#L196

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

I haven't contributed here yet, but it looks to me like File::options().read(true).write(true).create(true).truncate(true).open(path)? instead of File::create(path)? would fix this.

Should I make a PR? I unfortunately don't have a computer good enough to compile locally atm.

@klensy
Copy link
Contributor Author

klensy commented Aug 26, 2022

That should probably works, File::options().read(true).write(true).create(true).truncate(true).open(path)?, but looks little hacky.

@isikkema
Copy link

That should probably works, File::options().read(true).write(true).create(true).truncate(true).open(path)?, but looks little hacky.

I agree it looks wonky, but the only other option would be storing the path in FileEncoder and then creating a new read handle on it later, AFAIK. <-- I like this option much less.

@matthiaskrgr
Copy link
Member

bash mvce

rustc --crate-type lib -Zmeta-stats  - <<'EOF'

pub fn a() {}

EOF

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 28, 2022
notriddle added a commit to notriddle/rust that referenced this issue Sep 20, 2022
…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.
@bors bors closed this as completed in 3f377d3 Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants