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

Broken MIR Compiler bug #118030

Closed
ActuallyHappening opened this issue Nov 18, 2023 · 2 comments
Closed

Broken MIR Compiler bug #118030

ActuallyHappening opened this issue Nov 18, 2023 · 2 comments
Labels
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.

Comments

@ActuallyHappening
Copy link

I am very much enjoying programming in Rust! However, upon upgrading to stable 1.74 using bevy, I came across a strange compiler bug.

Code

// literally nothing, in src/lib.rs

Cargo.toml:

[package]
name = "creativity-game"
version = "0.0.0"
edition = "2021"

# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1

# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3

[dependencies.bevy_editor_pls]
# git = "https://github.com/jakobhellermann/bevy_editor_pls.git"
version = "0.6"
features = ["default_windows"]

I ran cargo b with no rust-toolchain.toml file

Meta

rustc --version --verbose:

binary: rustc
commit-hash: 79e9716c980570bfd1f666e3b16ac583f0168962
commit-date: 2023-11-13
host: aarch64-apple-darwin
release: 1.74.0
LLVM version: 17.0.4

This doesn't compile on the stable 1.74 channel, cargo +stable b, but compiles fine on nightly:

rustc 1.75.0-nightly (31bc7e2c4 2023-10-30)
binary: rustc
commit-hash: 31bc7e2c47e82798a392c770611975a6883132c8
commit-date: 2023-10-30
host: aarch64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.3

Also, it compiles fine on previous 1.73 stable version, making this a regression:

rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: aarch64-apple-darwin
release: 1.73.0
LLVM version: 17.0.2

Error output

(see backtrace below)

Backtrace

(on shell after having unsuccessfully built it after cargo clean)> RUST_BACKTRACE=1 cargo b
   Compiling bevy-inspector-egui v0.21.0
   Compiling bevy_editor_pls_core v0.6.0
   Compiling bevy_editor_pls_default_windows v0.6.0
   Compiling bevy_editor_pls v0.6.0
   Compiling creativity-game v0.0.0 (/Users/ah/Desktop/testing-bug)
error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in Item(DefId(0:154 ~ bevy_inspector_egui[3cc2]::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:2228 ~ bevy_inspector_egui[3cc2]::restricted_world_view::{impl#3}::get_entity_component_reflect::{opaque#0}) }) does not have fields
   --> /Users/ah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy-inspector-egui-0.21.0/src/bevy_inspector/mod.rs:415:17
    |
415 |                 set_changed();
    |                 ^^^^^^^^^^^
    |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:94:25
         0: std::backtrace::Backtrace::create
         1: <rustc_errors::HandlerInner>::emit_diagnostic
         2: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         3: <rustc_const_eval::transform::validate::CfgChecker>::fail::<alloc::string::String>
         4: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::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::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         8: <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
         9: 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>
        10: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
        11: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
        12: <rustc_middle::ty::context::TyCtxt>::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: <core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::disabled::par_for_each_in<alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, 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::<alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}>
        30: <rustc_session::session::Session>::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::<rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        34: <rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        35: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, 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::<rustc_codegen_llvm::LlvmCodegenBackend>
        38: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
        39: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
        40: rustc_interface::passes::start_codegen
        41: <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>>
        42: <rustc_interface::queries::Queries>::ongoing_codegen
        43: 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}>
        44: 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>>
        45: <<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}
        46: std::sys::unix::thread::Thread::new::thread_start
        47: __pthread_joiner_wake
   --> /Users/ah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy-inspector-egui-0.21.0/src/bevy_inspector/mod.rs:415:17
    |
415 |                 set_changed();
    |                 ^^^^^^^^^^^

error: internal compiler error: broken MIR in Item(DefId(0:154 ~ bevy_inspector_egui[3cc2]::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:2228 ~ bevy_inspector_egui[3cc2]::restricted_world_view::{impl#3}::get_entity_component_reflect::{opaque#0}) }) does not have fields
   --> /Users/ah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy-inspector-egui-0.21.0/src/bevy_inspector/mod.rs:415:17
    |
415 |                 set_changed();
    |                 ^^^^^^^^^^^
    |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:94:25
         0: std::backtrace::Backtrace::create
         1: <rustc_errors::HandlerInner>::emit_diagnostic
         2: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
         3: <rustc_const_eval::transform::validate::CfgChecker>::fail::<alloc::string::String>
         4: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::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::<rustc_query_impl::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         8: <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
         9: 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>
        10: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
        11: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
        12: <rustc_middle::ty::context::TyCtxt>::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: <core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::disabled::par_for_each_in<alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, 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::<alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}>
        30: <rustc_session::session::Session>::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::<rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
        34: <rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        35: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, 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::<rustc_codegen_llvm::LlvmCodegenBackend>
        38: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
        39: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
        40: rustc_interface::passes::start_codegen
        41: <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>>
        42: <rustc_interface::queries::Queries>::ongoing_codegen
        43: 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}>
        44: 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>>
        45: <<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}
        46: std::sys::unix::thread::Thread::new::thread_start
        47: __pthread_joiner_wake
   --> /Users/ah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy-inspector-egui-0.21.0/src/bevy_inspector/mod.rs:415:17
    |
415 |                 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 -C debuginfo=2 -C split-debuginfo=unpacked -C debug-assertions=on

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)
warning: build failed, waiting for other jobs to finish...

@ActuallyHappening ActuallyHappening 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 Nov 18, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 18, 2023
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 18, 2023
@saethlin
Copy link
Member

I'm closing this as a direct duplicate of #118025 but still thank you for reporting this. I'd rather see us close the occasional duplicate than have people not speak up when they have a problem.

@ActuallyHappening
Copy link
Author

Oh thanks, yes I agree I will still report bugs but didn't see mine was duplicate

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. 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

No branches or pull requests

3 participants