rust-lang / rust

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

1.74 causes an internal compiler error: broken MIR in Item #117976

Closed Haaroon closed 9 months ago

Haaroon commented 10 months ago

Meta

rustc 1.74.0 (79e9716c9 2023-11-13) running on x86_64-unknown-linux-gnu

Error output

    Compiling tantivy v0.20.2
   Compiling raphtory v0.6.1 (/home/runner/work/Raphtory/Raphtory/raphtory)
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(DefId(0:7815 ~ tantivy[41bc]::store::reader::{impl#3}::iter_raw::{closure#2})) (after phase change to runtime-optimized) at bb2[6]:
                                Alias(Opaque, AliasTy { args: [ReErased], def_id: DefId(0:18126 ~ tantivy[41bc]::store::reader::{impl#3}::block_checkpoints::{opaque#0}) }) does not have fields
 --> /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/iter/adapters/flatten.rs:52:9
  |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:94:25
         0: <rustc_errors::HandlerInner>::emit_diagnostic
         1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         2: <rustc_const_eval::transform::validate::CfgChecker>::fail::<alloc::string::String>
         3: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
         4: rustc_mir_transform::pass_manager::run_passes
         5: rustc_mir_transform::optimized_mir
         6: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         7: <rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
         8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
         9: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
        10: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
        11: rustc_metadata::rmeta::encoder::encode_metadata_impl
        12: rustc_data_structures::sync::parallel::disabled::join::<rustc_metadata::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
        13: rustc_metadata::rmeta::encoder::encode_metadata
        14: rustc_metadata::fs::encode_and_write_metadata
        15: rustc_interface::passes::start_codegen
        16: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
        17: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
        18: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        19: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        20: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/alloc/src/boxed.rs:2007:9
        21: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/alloc/src/boxed.rs:2007:9
        22: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/sys/unix/thread.rs:108:17
        23: <unknown>
        24: <unknown>
 --> /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/iter/adapters/flatten.rs:52:9

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.74.0 (79e9716c9 2023-11-13) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type rlib -C opt-level=3 -C embed-bitcode=no

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `tantivy` (lib)
warning: build failed, waiting for other jobs to finish...
warning: unused import: `TimeIndex`
 --> raphtory/src/db/graph/views/deletion_graph.rs:8:38
  |
8 |         storage::timeindex::{AsTime, TimeIndex, TimeIndexEntry, TimeIndexOps},
  |                                      ^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `window_graph::WindowedGraph`
  --> raphtory/src/python/graph/edge.rs:27:17
   |
27 |                 window_graph::WindowedGraph,
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `window_graph::WindowedGraph`
  --> raphtory/src/python/graph/vertex.rs:24:17
   |
24 |                 window_graph::WindowedGraph,
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused variable: `active`
   --> raphtory/src/db/graph/views/deletion_graph.rs:280:13
    |
280 |         let active = e.active(layer_ids, w.clone());
    |             ^^^^^^ help: if this is intentional, prefix it with an underscore: `_active`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `alive`
   --> raphtory/src/db/graph/views/deletion_graph.rs:281:13
    |
281 |         let alive = self.edge_alive_at(e, w.start, layer_ids);
    |             ^^^^^ help: if this is intentional, prefix it with an underscore: `_alive`

warning: fields `content` and `entity` are never read
  --> raphtory/src/python/packages/vectors.rs:25:5
   |
24 | struct PyGraphDocument {
   |        --------------- fields in this struct
25 |     content: String,
   |     ^^^^^^^
26 |     entity: PyObject,
   |     ^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: 6 warnings emitted

💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `"cargo" "rustc" "--release" "--features" "pyo3/extension-module" "--message-format" "json" "--lib"`
Error: The process '/home/runner/work/_temp/96516ff6-5310-4537-8510-8a8e1cea03b2/maturin' failed with exit code 1
Error: The process '/home/runner/work/_temp/96516ff6-5310-4537-8510-8a8e1cea03b2/maturin' failed with exit code 1
    at ExecState._setResult (/home/runner/work/_actions/PyO3/maturin-action/v1/dist/index.js:1702:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/PyO3/maturin-action/v1/dist/index.js:1685:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/PyO3/maturin-action/v1/dist/index.js:1579:27)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
```

see action for more https://github.com/Pometry/Raphtory/actions/runs/6891668769/job/18749095180
lqd commented 10 months ago

@Haaroon could you please describe how can we reproduce the issue? Thank you.

matthiaskrgr commented 10 months ago

I wonder if this is https://github.com/rust-lang/rust/issues/116332 which has already been fixed in latest nightly :thinking:

lqd commented 10 months ago

type alias impl trait is not stable though, so the reproducers will be at least different 🤔

matthiaskrgr commented 10 months ago

Hmm right.

lqd commented 10 months ago

Alright, I found a way to reproduce the issue from this project's dependencies: building tantivy-0.21.1 in release mode is enough to trigger the ICE.

Some good news: it doesn't ICE on nightly, nor on beta.

I will work on bisecting the involved PRs to see what could need a stable backport.

lqd commented 10 months ago

@matthiaskrgr you had the right intuition: the change in #115759 impacted more than unstable code and caused this ICE (as well as many others of course), and was fixed by #116415. The repro is different from #116332 but the cause and fix are indeed the same.

matthiaskrgr commented 10 months ago

yay, all the time staring at compiler crashes finally payed out!

lqd commented 10 months ago

Incredible: #116333.

matthiaskrgr commented 10 months ago

lol, crap... We need a better tracking of what to beta backport at the right time :/

Haaroon commented 10 months ago

@Haaroon could you please describe how can we reproduce the issue? Thank you.

I beleive it was because i tried to build tantivy with the release flag with maturin

rsalmei commented 10 months ago

I also can't run anymore a project I used to. It now breaks with a similar error when compiling bevy-inspector-egui v0.19.0. I'm on a macOS with M1.

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(DefId(0:152 ~ bevy_inspector_egui[68b7]::bevy_inspector::ui_for_entity_components::{closure#3})) (after phase change to runtime-optimized) at bb5[4]:
                                Alias(Opaque, AliasTy { args: [ReErased, ReErased], def_id: DefId(0:2162 ~ bevy_inspector_egui[68b7]::restricted_world_view::{impl#3}::get_entity_component_reflect::{opaque#0}) }) does not have fields

The code is public if you'd like another repo to test it: https://github.com/danieldidiobalsamo/boids

Trace ``` cargo run --release Compiling bevy-inspector-egui v0.19.0 error: internal compiler error: no errors encountered even though `delay_span_bug` issued error: internal compiler error: broken MIR in Item(DefId(0:152 ~ bevy_inspector_egui[68b7]::bevy_inspector::ui_for_entity_components::{closure#3})) (after phase change to runtime-optimized) at bb5[4]: Alias(Opaque, AliasTy { args: [ReErased, ReErased], def_id: DefId(0:2162 ~ bevy_inspector_egui[68b7]::restricted_world_view::{impl#3}::get_entity_component_reflect::{opaque#0}) }) does not have fields --> /Users/rogerio/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy-inspector-egui-0.19.0/src/bevy_inspector/mod.rs:401:17 | 401 | set_changed(); | ^^^^^^^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:94:25 0: std::backtrace::Backtrace::create 1: ::emit_diagnostic 2: ::delay_span_bug:: 3: ::fail:: 4: ::run_pass 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::optimized_mir 7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 8: >::call_once 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace 11: rustc_middle::query::plumbing::query_get_at::>> 12: ::instance_mir 13: rustc_monomorphize::collector::collect_used_items 14: rustc_monomorphize::collector::collect_items_rec 15: rustc_monomorphize::collector::collect_items_rec 16: rustc_monomorphize::collector::collect_items_rec 17: rustc_monomorphize::collector::collect_items_rec 18: rustc_monomorphize::collector::collect_items_rec 19: rustc_monomorphize::collector::collect_items_rec 20: rustc_monomorphize::collector::collect_items_rec 21: rustc_monomorphize::collector::collect_items_rec 22: rustc_monomorphize::collector::collect_items_rec 23: rustc_monomorphize::collector::collect_items_rec 24: rustc_monomorphize::collector::collect_items_rec 25: rustc_monomorphize::collector::collect_items_rec 26: rustc_monomorphize::collector::collect_items_rec 27: rustc_monomorphize::collector::collect_items_rec 28: , rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once 29: rustc_data_structures::sync::parallel::disabled::par_for_each_in::, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}> 30: ::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}> 31: rustc_monomorphize::collector::collect_crate_mono_items 32: rustc_monomorphize::partitioning::collect_and_partition_mono_items 33: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 34: >::call_once 35: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 36: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace 37: rustc_codegen_ssa::base::codegen_crate:: 38: ::codegen_crate 39: ::time::, rustc_interface::passes::start_codegen::{closure#0}> 40: rustc_interface::passes::start_codegen 41: ::enter::<::ongoing_codegen::{closure#0}, core::result::Result, rustc_span::ErrorGuaranteed>> 42: ::ongoing_codegen 43: rustc_span::set_source_map::, rustc_interface::interface::run_compiler, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 44: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 45: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 46: std::sys::unix::thread::Thread::new::thread_start 47: __pthread_joiner_wake --> /Users/rogerio/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy-inspector-egui-0.19.0/src/bevy_inspector/mod.rs:401:17 | 401 | set_changed(); | ^^^^^^^^^^^ error: internal compiler error: broken MIR in Item(DefId(0:152 ~ bevy_inspector_egui[68b7]::bevy_inspector::ui_for_entity_components::{closure#3})) (after phase change to runtime-optimized) at bb5[5]: Alias(Opaque, AliasTy { args: [ReErased, ReErased], def_id: DefId(0:2162 ~ bevy_inspector_egui[68b7]::restricted_world_view::{impl#3}::get_entity_component_reflect::{opaque#0}) }) does not have fields --> /Users/rogerio/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy-inspector-egui-0.19.0/src/bevy_inspector/mod.rs:401:17 | 401 | set_changed(); | ^^^^^^^^^^^ | note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:94:25 0: std::backtrace::Backtrace::create 1: ::emit_diagnostic 2: ::delay_span_bug:: 3: ::fail:: 4: ::run_pass 5: rustc_mir_transform::pass_manager::run_passes_inner 6: rustc_mir_transform::optimized_mir 7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 8: >::call_once 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace 11: rustc_middle::query::plumbing::query_get_at::>> 12: ::instance_mir 13: rustc_monomorphize::collector::collect_used_items 14: rustc_monomorphize::collector::collect_items_rec 15: rustc_monomorphize::collector::collect_items_rec 16: rustc_monomorphize::collector::collect_items_rec 17: rustc_monomorphize::collector::collect_items_rec 18: rustc_monomorphize::collector::collect_items_rec 19: rustc_monomorphize::collector::collect_items_rec 20: rustc_monomorphize::collector::collect_items_rec 21: rustc_monomorphize::collector::collect_items_rec 22: rustc_monomorphize::collector::collect_items_rec 23: rustc_monomorphize::collector::collect_items_rec 24: rustc_monomorphize::collector::collect_items_rec 25: rustc_monomorphize::collector::collect_items_rec 26: rustc_monomorphize::collector::collect_items_rec 27: rustc_monomorphize::collector::collect_items_rec 28: , rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once 29: rustc_data_structures::sync::parallel::disabled::par_for_each_in::, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}> 30: ::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}> 31: rustc_monomorphize::collector::collect_crate_mono_items 32: rustc_monomorphize::partitioning::collect_and_partition_mono_items 33: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 34: >::call_once 35: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 36: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace 37: rustc_codegen_ssa::base::codegen_crate:: 38: ::codegen_crate 39: ::time::, rustc_interface::passes::start_codegen::{closure#0}> 40: rustc_interface::passes::start_codegen 41: ::enter::<::ongoing_codegen::{closure#0}, core::result::Result, rustc_span::ErrorGuaranteed>> 42: ::ongoing_codegen 43: rustc_span::set_source_map::, rustc_interface::interface::run_compiler, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 44: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 45: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 46: std::sys::unix::thread::Thread::new::thread_start 47: __pthread_joiner_wake --> /Users/rogerio/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy-inspector-egui-0.19.0/src/bevy_inspector/mod.rs:401:17 | 401 | set_changed(); | ^^^^^^^^^^^ 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.74.0 (79e9716c9 2023-11-13) running on aarch64-apple-darwin note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no note: some of the compiler flags provided by cargo are hidden query stack during panic: end of query stack error: could not compile `bevy-inspector-egui` (lib) ```
lqd commented 10 months ago

Yeah #118025 showed the issue also happening on bevy_inspector_egui.

martinmr commented 10 months ago

Also seeing this issue on my own project. Here's it failing on a PR that's just fixing a couple of lints:

apiraino commented 10 months ago

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

asahilina commented 9 months ago

I ran into this building a Rust for Linux driver. That codebase is probably even more complicated than the other examples here, so I'm not sure how useful it is, but just in case, here's the tree: https://github.com/AsahiLinux/linux/tree/gpu/rust-1.74-ice . You have to build for ARM64, I can provide more instructions if needed.

The topmost commit in that branch works around the ICE. Reverting it causes it to come back.

apiraino commented 9 months ago

@rustbot label -P-high +P-critical

freedit-dev commented 9 months ago

Is there a minor release?

apiraino commented 9 months ago

@freedit-dev Yes, there will be a 1.74.1 release to fix some issues (#118607).

We are trying to also backport in some form #116415 to fix this issue as well (if I'm connecting the dots correctly)

davidtwco commented 9 months ago

As I understand it, this should be fixed by the backports in the 1.74.1 release, but I'll label this as needs-test so we can make sure it doesn't regress in future.

lqd commented 9 months ago

The test is this repro https://github.com/rust-lang/rust/issues/116333#issuecomment-1745705014 and was added in https://github.com/rust-lang/rust/pull/116415#issuecomment-1749189835.

Closing as fixed.