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

ICE: broken mir with -Zprint-mono-items=eager between passes RemoveStorageMarkers and Inline #114458

Closed
matthiaskrgr opened this issue Aug 4, 2023 · 3 comments
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

rustc --edition=2021 -Zvalidate-mir -Zmir-opt-level=3 --crate-type lib -Zprint-mono-items=eager

struct A;
struct B;

impl Drop for A {
    fn drop(&mut self) {}
}
impl Drop for B {
    fn drop(&mut self) {}
}

#[inline(always)]
fn no_unwind() {}

fn drop(a: A, b: B, nothing: ((), (), ()), x: bool) -> ((), (), ()) {
    'scope: {
        (
            {
                let _z = b;
                if x {
                    break 'scope nothing;
                }
            },
            match { a } {
                _ => (),
            },
            no_unwind(),
        )
    }
}

Meta

rustc --version --verbose:

<version>

Error output

warning: function `no_unwind` is never used
  --> treereduce.out:12:4
   |
12 | fn no_unwind() {}
   |    ^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: function `drop` is never used
  --> treereduce.out:14:4
   |
14 | fn drop(a: A, b: B, nothing: ((), (), ()), x: bool) -> ((), (), ()) {
   |    ^^^^

MONO_ITEM fn <A as std::ops::Drop>::drop @@ treereduce.543681524c8c906e-cgu.0[External]
MONO_ITEM fn <B as std::ops::Drop>::drop @@ treereduce.543681524c8c906e-cgu.0[External]
MONO_ITEM fn drop @@ treereduce.543681524c8c906e-cgu.0[Internal]
MONO_ITEM fn no_unwind @@
MONO_ITEM fn std::ptr::drop_in_place::<A> - shim(Some(A)) @@ treereduce.543681524c8c906e-cgu.0[External]
MONO_ITEM fn std::ptr::drop_in_place::<B> - shim(Some(B)) @@ treereduce.543681524c8c906e-cgu.0[External]
warning: 2 warnings emitted
Backtrace

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

error: internal compiler error: broken MIR in Item(DefId(0:12 ~ treereduce[5436]::drop)) (after pass Inline) at bb11[0]:
                                use of local _10, which has no storage here
  --> treereduce.out:29:1
   |
29 | }
   | ^
   |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:274:22
         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::CfgChecker as rustc_middle::mir::visit::Visitor>::visit_terminator
         4: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
         5: rustc_mir_transform::pass_manager::validate_body
         6: rustc_mir_transform::pass_manager::run_passes
         7: rustc_mir_transform::optimized_mir
         8: 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]>>
         9: <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
        10: 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>
        11: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
        12: <rustc_middle::ty::context::TyCtxt>::instance_mir
        13: rustc_monomorphize::collector::collect_used_items
        14: rustc_monomorphize::collector::collect_items_rec
        15: rustc_data_structures::sync::par_for_each_in::<alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}>
        16: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
        17: rustc_monomorphize::collector::collect_crate_mono_items
        18: rustc_monomorphize::partitioning::collect_and_partition_mono_items
        19: 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]>>
        20: <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
        21: 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>
        22: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
        23: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
        24: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::exported_symbols::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
        25: <rustc_query_impl::query_impl::exported_symbols::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::CrateNum)>>::call_once
        26: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::CrateNum, rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        27: rustc_query_impl::query_impl::exported_symbols::get_query_non_incr::__rust_end_short_backtrace
        28: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
        29: rustc_metadata::rmeta::encoder::encode_metadata_impl
        30: rustc_metadata::rmeta::encoder::encode_metadata
        31: rustc_metadata::fs::encode_and_write_metadata
        32: rustc_interface::passes::start_codegen
        33: <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>>
        34: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
        35: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_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>>
        36: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_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}
        37: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/474709a9a2a74a8bcf0055fadb335d0ca0d2d939/library/alloc/src/boxed.rs:2007:9
        38: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/474709a9a2a74a8bcf0055fadb335d0ca0d2d939/library/alloc/src/boxed.rs:2007:9
        39: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/474709a9a2a74a8bcf0055fadb335d0ca0d2d939/library/std/src/sys/unix/thread.rs:108:17
        40: <unknown>
        41: <unknown>
  --> treereduce.out:29:1
   |
29 | }
   | ^

error: internal compiler error: broken MIR in Item(DefId(0:12 ~ treereduce[5436]::drop)) (before pass RemoveStorageMarkers) at bb11[0]:
                                use of local _10, which has no storage here
  --> treereduce.out:29:1
   |
29 | }
   | ^
   |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:274:22
         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::CfgChecker as rustc_middle::mir::visit::Visitor>::visit_terminator
         4: <rustc_const_eval::transform::validate::Validator as rustc_middle::mir::MirPass>::run_pass
         5: rustc_mir_transform::pass_manager::validate_body
         6: rustc_mir_transform::pass_manager::run_passes
         7: rustc_mir_transform::optimized_mir
         8: 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]>>
         9: <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
        10: 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>
        11: rustc_query_impl::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
        12: <rustc_middle::ty::context::TyCtxt>::instance_mir
        13: rustc_monomorphize::collector::collect_used_items
        14: rustc_monomorphize::collector::collect_items_rec
        15: rustc_data_structures::sync::par_for_each_in::<alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}>
        16: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
        17: rustc_monomorphize::collector::collect_crate_mono_items
        18: rustc_monomorphize::partitioning::collect_and_partition_mono_items
        19: 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]>>
        20: <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
        21: 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>
        22: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
        23: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
        24: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::exported_symbols::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
        25: <rustc_query_impl::query_impl::exported_symbols::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::CrateNum)>>::call_once
        26: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::CrateNum, rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        27: rustc_query_impl::query_impl::exported_symbols::get_query_non_incr::__rust_end_short_backtrace
        28: <rustc_metadata::rmeta::encoder::EncodeContext>::encode_crate_root
        29: rustc_metadata::rmeta::encoder::encode_metadata_impl
        30: rustc_metadata::rmeta::encoder::encode_metadata
        31: rustc_metadata::fs::encode_and_write_metadata
        32: rustc_interface::passes::start_codegen
        33: <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>>
        34: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
        35: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_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>>
        36: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_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}
        37: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/474709a9a2a74a8bcf0055fadb335d0ca0d2d939/library/alloc/src/boxed.rs:2007:9
        38: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/474709a9a2a74a8bcf0055fadb335d0ca0d2d939/library/alloc/src/boxed.rs:2007:9
        39: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/474709a9a2a74a8bcf0055fadb335d0ca0d2d939/library/std/src/sys/unix/thread.rs:108:17
        40: <unknown>
        41: <unknown>
  --> treereduce.out:29:1
   |
29 | }
   | ^

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: please attach the file at `/tmp/im/rustc-ice-2023-08-04T10:37:35.619636055Z-1344212.txt` to your bug report

note: compiler flags: -Z validate-mir -Z mir-opt-level=3 --crate-type lib -Z print-mono-items=eager

query stack during panic:
end of query stack

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. labels Aug 4, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 4, 2023
@matthiaskrgr matthiaskrgr changed the title ICE: broken mir with -Zprint-mono-items=eager ICE: broken mir with -Zprint-mono-items=eager between passes RemoveStorageMarkers and Inline Aug 4, 2023
@matthiaskrgr
Copy link
Member Author

Regression in nightly-2022-08-26

found 6 bors merge commits in the specified range
commit[0] 2022-08-24: Auto merge of #100963 - matthiaskrgr:rollup-pjr0lb3, r=matthiaskrgr
commit[1] 2022-08-24: Auto merge of #99946 - tmiasko:elide-storage-makers, r=oli-obk
commit[2] 2022-08-25: Auto merge of #100977 - JohnTitor:rollup-8hc7rxh, r=JohnTitor
commit[3] 2022-08-25: Auto merge of #100436 - jyn514:macro-query-system, r=cjgillot
commit[4] 2022-08-25: Auto merge of #100571 - cjgillot:mir-cost-visit, r=compiler-errors
commit[5] 2022-08-25: Auto merge of #100911 - tmiasko:update-stdarch, r=Amanieu
ERROR: no CI builds available between addacb5 and 7480389 within last 167 days

@matthiaskrgr
Copy link
Member Author

Hmm need to check if this is a duplicate of #104736

@matthiaskrgr matthiaskrgr self-assigned this Aug 4, 2023
@matthiaskrgr
Copy link
Member Author

yup, its a dupe

@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 8, 2023
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) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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