rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.06k stars 12.8k forks source link

Regression: rustc crashes on Windows trying to build lib/rustlib/x86_64-pc-windows-msvc/lib/libstd.rlib #118754

Closed nico closed 11 months ago

nico commented 11 months ago

Meta

Trying to update rustc from df0295f07175acc7325ce3ca4152eb05752af1f2 to f90f898fa53de89a1cb274442c90c410075ae731 in Chromium, we hit an ICE. So far I've only seen it on a bot and don't have a local repro yet.

Error output

The full error log is at https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8762255204440933329/+/u/compile__with_patch_/stdout?format=raw

Excerpt:

Backtrace

``` FAILED: 444ffa45-8bad-4945-8d57-26a434e09e2b RUST local_rustc_sysroot/lib/rustlib/x86_64-pc-windows-msvc/lib/libstd.rlib stderr: error: internal compiler error: compiler\rustc_mir_transform\src\coverage\spans.rs:434:49: invalid attempt to unwrap a None some_prev thread 'rustc' panicked at C:\b\s\w\ir\cache\builder\src\third_party\rust-src\compiler\rustc_errors\src\lib.rs:1113:75: Box stack backtrace: 0: 0x7ffb7e23a2f5 - ::fmt::hd599614fd193bada 1: 0x7ffb7e26ef8b - core::fmt::write::hda39c3c02411710a 2: 0x7ffb7e243201 - std::fs::DirBuilder::_create::h5d831723ad01bc5b 3: 0x7ffb7e23bc24 - std::panicking::default_hook::h66d8ac9069df83d4 4: 0x7ffb7e23b4ba - std::panicking::default_hook::h66d8ac9069df83d4 5: 0x7ffb74047612 - once_cell[96842b08614cf476]::imp::initialize_or_wait 6: 0x7ffb7e23c60d - std::panicking::rust_panic_with_hook::hcc951e9133c0ca78 7: 0x7ffb73dc5f2a - rustc_errors[4b6d00e9ad1f5418]::markdown::create_stdout_bufwtr 8: 0x7ffb73dc3cc9 - rustc_errors[4b6d00e9ad1f5418]::markdown::create_stdout_bufwtr 9: 0x7ffb76f489b9 - rustc_query_system[d461914d3def57f8]::query::job::report_cycle 10: 0x7ffb73dcb42c - ::diagnostic_builder_emit_producing_guarantee 11: 0x7ffb73bedd9e - ::fmt 12: 0x7ffb73bc7f94 - ::fmt 13: 0x7ffb73bc4571 - ::into_diagnostic_arg 14: 0x7ffb73bc450f - ::into_diagnostic_arg 15: 0x7ffb76f37045 - rustc_middle[3d57c46152fca3ab]::util::bug::bug_fmt 16: 0x7ffb7280d620 - ::run_pass 17: 0x7ffb72809f95 - ::run_pass 18: 0x7ffb72855d3f - ::drop_style 19: 0x7ffb72904863 - rustc_mir_transform[b009732a92ad6572]::mir_promoted 20: 0x7ffb7309fa64 - ::depth_limit_error 21: 0x7ffb7317c8e1 - rustc_query_impl[835115f851c09ed8]::query_callbacks 22: 0x7ffb74d4a502 - once_cell[96842b08614cf476]::imp::initialize_or_wait 23: 0x7ffb74daa86f - once_cell[96842b08614cf476]::imp::initialize_or_wait 24: 0x7ffb72e21dac - rustc_borrowck[6d4f4eabd77ba1f0]::mir_borrowck 25: 0x7ffb7309f9ff - ::depth_limit_error 26: 0x7ffb74bb6bdc - once_cell[96842b08614cf476]::imp::initialize_or_wait 27: 0x7ffb74d59688 - once_cell[96842b08614cf476]::imp::initialize_or_wait 28: 0x7ffb730cd43f - rustc_query_impl[835115f851c09ed8]::profiling_support::alloc_self_profile_query_strings 29: 0x7ffb722e618b - rustc_interface[80035a4c85fe31c5]::passes::start_codegen 30: 0x7ffb740c4445 - once_cell[96842b08614cf476]::imp::initialize_or_wait 31: 0x7ffb722e1407 - rustc_interface[80035a4c85fe31c5]::passes::analysis 32: 0x7ffb730a5f0d - ::depth_limit_error 33: 0x7ffb731806a8 - rustc_query_impl[835115f851c09ed8]::query_callbacks 34: 0x7ffb74c78c8a - once_cell[96842b08614cf476]::imp::initialize_or_wait 35: 0x7ffb74bbd353 - once_cell[96842b08614cf476]::imp::initialize_or_wait 36: 0x7ffb721a22ef - 37: 0x7ffb7406f674 - once_cell[96842b08614cf476]::imp::initialize_or_wait 38: 0x7ffb74048b52 - once_cell[96842b08614cf476]::imp::initialize_or_wait 39: 0x7ffb7403d1ce - once_cell[96842b08614cf476]::imp::initialize_or_wait 40: 0x7ffb740514c6 - once_cell[96842b08614cf476]::imp::initialize_or_wait 41: 0x7ffb721a759a - <::panic_nounwind::Zst as rustc_middle[3d57c46152fca3ab]::mir::interpret::error::MachineStopType>::add_args 42: 0x7ffb7e23d02c - std::sys::windows::thread::Thread::new::h74332cb458a081a6 43: 0x7ffbc6ae7034 - BaseThreadInitThunk 44: 0x7ffbc82226a1 - RtlUserThreadStart ```

It looks like https://github.com/rust-lang/rust/commits/master/compiler/rustc_errors/src was edited quite a bit 4 days ago by @nnethercote; maybe the stack trace will make sense to them.

I'll try to add more information as I get it.

nico commented 11 months ago

(upstream issue: https://bugs.chromium.org/p/chromium/issues/detail?id=1509925)

nico commented 11 months ago

(Our last update included Rust changes up to Nov 28, so the rustc_errors changes on Dec 1 are in scope too. Apologies if this is some very central code and the bug is likely in a caller than in that code in particular! I don't know very much about rustc's internal structure.)

nico commented 11 months ago

I managed to reproduce the problem locally. Here's the error log that rustc asks me to upload:

rustc-ice-2023-12-08T19_42_07-2444121.txt

nnethercote commented 11 months ago

The relevant parts of the stack trace:

  15:     0x7ffb76f37045 - rustc_middle[3d57c46152fca3ab]::util::bug::bug_fmt
  16:     0x7ffb7280d620 - <rustc_mir_transform[b009732a92ad6572]::coverage::InstrumentCoverage as rustc_middle[3d57c46152fca3ab]::mir::MirPass>::run_pass
  17:     0x7ffb72809f95 - <rustc_mir_transform[b009732a92ad6572]::coverage::InstrumentCoverage as rustc_middle[3d57c46152fca3ab]::mir::MirPass>::run_pass
  18:     0x7ffb72855d3f - <rustc_mir_transform[b009732a92ad6572]::elaborate_drops::Elaborator as rustc_mir_dataflow[17d83a6078baa8de]::elaborate_drops::DropElaborator>::drop_style
  19:     0x7ffb72904863 - rustc_mir_transform[b009732a92ad6572]::mir_promoted

This looks like a problem in InstrumentCoverage, which is a MIR pass. I don't know anything about it beyond that. Maybe @saethlin or @cjgillot might know?

Urgau commented 11 months ago

Seems like a duplicate of https://github.com/rust-lang/rust/issues/118643. Which I think will be fixed by https://github.com/rust-lang/rust/pull/118666.

cc @Zalathar

Zalathar commented 11 months ago

Yeah, from the panic message this looks like the same issue.

Zalathar commented 11 months ago

This should now be fixed in 1.76.0-nightly (06e02d5b2 2023-12-09).

nico commented 11 months ago

Yes, we're no longer seeing this, thanks!