Skip to content

ICE: broken mir while building rustc #114375

Closed

Description

@matthiaskrgr

Code

rustc -Zvalidate-mir file.rs

#![feature(rustc_private)]

extern crate rustc_parse;
extern crate rustc_session;
extern crate rustc_span;

extern crate rustc_driver;

use rustc_session::parse::ParseSess;
use rustc_span::source_map::FilePathMapping;

fn main() {
    rustc_span::create_default_session_globals_then(|| run());
}

fn run() {
    let ps = ParseSess::new(
        vec![rustc_parse::DEFAULT_LOCALE_RESOURCE],
        FilePathMapping::empty(),
    );
}

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (d12c6e947 2023-08-01)
binary: rustc
commit-hash: d12c6e947ceacf3b22c154caf9532b390d8dc88a
commit-date: 2023-08-01
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Error output

<output>

Not posting the entire 1.7K lines backtrace 🙃

Backtrace

warning: unused variable: `ps`
  --> treereduce.out:19:9
   |
19 |     let ps = ParseSess::new(
   |         ^^ help: if this is intentional, prefix it with an underscore: `_ps`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

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

error: internal compiler error: broken MIR in DropGlue(DefId(2:2152 ~ core[9b2a]::ptr::drop_in_place), Some(std::backtrace::Inner)) (before pass AddMovesFor>
                                Field projection `PlaceRef { local: _1, projection: [Deref, Downcast(Some("Captured"), 2)] }.0` specified type `std::sync::L>
   --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:497:1
    |
497 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:76: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::validate_body
         5: rustc_mir_transform::pass_manager::run_passes
         6: rustc_mir_transform::shim::make_shim
         7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_shims::dynamic_query::{closure#2}::{closure#0}, rus>
         8: <rustc_query_impl::query_impl::mir_shims::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_mi>
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_m>
        10: rustc_query_impl::query_impl::mir_shims::get_query_non_incr::__rust_end_short_backtrace
        11: <rustc_middle::ty::context::TyCtxt>::instance_mir
        12: rustc_monomorphize::collector::collect_used_items
        13: rustc_monomorphize::collector::collect_items_rec
        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_items_rec
        29: rustc_monomorphize::collector::collect_items_rec
        30: rustc_monomorphize::collector::collect_items_rec
        31: rustc_data_structures::sync::par_for_each_in::<alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, rustc_monomorphize::collector::collect_crate_>
        32: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
        33: rustc_monomorphize::collector::collect_crate_mono_items
        34: rustc_monomorphize::partitioning::collect_and_partition_mono_items
        35: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closu>
        36: <rustc_query_impl::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::co>
        37: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_mi>
        38: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
        39: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
        40: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
        41: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
        42: rustc_interface::passes::start_codegen
        43: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::>
        44: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Op>
        45: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::ru>
        46: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::>
        47: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/d12c6e947ceacf3b22c154caf9532b390d8dc88a/library/alloc/src/boxed.rs:2007:9
        48: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/d12c6e947ceacf3b22c154caf9532b390d8dc88a/library/alloc/src/boxed.rs:2007:9
        49: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/d12c6e947ceacf3b22c154caf9532b390d8dc88a/library/std/src/sys/unix/thread.rs:108:17
        50: <unknown>
        51: <unknown>
   --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:497:1
    |
497 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: broken MIR in DropGlue(DefId(2:2152 ~ core[9b2a]::ptr::drop_in_place), Some(std::backtrace::Inner)) (before pass AddMovesFor>
                                Field projection `PlaceRef { local: _1, projection: [Deref, Downcast(Some("Captured"), 2)] }.0` specified type `std::sync::L>
lines 42-82
        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_items_rec
        29: rustc_monomorphize::collector::collect_items_rec
        30: rustc_monomorphize::collector::collect_items_rec
        31: 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}>
        32: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
        33: rustc_monomorphize::collector::collect_crate_mono_items
        34: rustc_monomorphize::partitioning::collect_and_partition_mono_items
        35: 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]>>
        36: <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
        37: 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>
        38: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
        39: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
        40: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
        41: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
        42: rustc_interface::passes::start_codegen
        43: <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>>
        44: <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>>
        45: 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:>
        46: <<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>>
        47: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/d12c6e947ceacf3b22c154caf9532b390d8dc88a/library/alloc/src/boxed.rs:2007:9
        48: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/d12c6e947ceacf3b22c154caf9532b390d8dc88a/library/alloc/src/boxed.rs:2007:9
        49: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/d12c6e947ceacf3b22c154caf9532b390d8dc88a/library/std/src/sys/unix/thread.rs:108:17
        50: <unknown>
        51: <unknown>
   --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:497:1
    |
497 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: broken MIR in DropGlue(DefId(2:2152 ~ core[9b2a]::ptr::drop_in_place), Some(std::backtrace::Inner)) (before pass AddMovesForPackedDrops) at bb5[0]:
                                Field projection `PlaceRef { local: _1, projection: [Deref, Downcast(Some("Captured"), 2)] }.0` specified type `std::sync::LazyLock<std::backtrace::Capture, [closure@std::backtrace::lazy_resolve::{closure#0}]>`, but actual type is `std::sync::LazyLock<std::backtrace::Capture, std::back>
   --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:497:1
    |
497 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:76: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::validate_body
         5: rustc_mir_transform::pass_manager::run_passes
         6: rustc_mir_transform::shim::make_shim
         7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_shims::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         8: <rustc_query_impl::query_impl::mir_shims::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::instance::InstanceDef)>>::call_once
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::instance::InstanceDef, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        10: rustc_query_impl::query_impl::mir_shims::get_query_non_incr::__rust_end_short_backtrace
        11: <rustc_middle::ty::context::TyCtxt>::instance_mir
        12: rustc_monomorphize::collector::collect_used_items
        13: rustc_monomorphize::collector::collect_items_rec
        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_items_rec
        29: rustc_monomorphize::collector::collect_items_rec
        30: rustc_monomorphize::collector::collect_items_rec
        31: 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}>
        32: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
        33: rustc_monomorphize::collector::collect_crate_mono_items
        34: rustc_monomorphize::partitioning::collect_and_partition_mono_items
        35: 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]>>
        36: <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
        37: 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>
        38: rustc_query_impl::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
        39: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
        40: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
        41: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
        42: rustc_interface::passes::start_codegen
        43: <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>>
        44: <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>>
        45: 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:>
        46: <<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>>
        47: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/d12c6e947ceacf3b22c154caf9532b390d8dc88a/library/alloc/src/boxed.rs:2007:9
        48: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/d12c6e947ceacf3b22c154caf9532b390d8dc88a/library/alloc/src/boxed.rs:2007:9
        49: std::sys::unix::thread::Thread::new::thread_start
                   at /rustc/d12c6e947ceacf3b22c154caf9532b390d8dc88a/library/std/src/sys/unix/thread.rs:108:17
        50: <unknown>
        51: <unknown>
   --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:497:1
    |
497 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Aug 2, 2023
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 2, 2023
  3. matthiaskrgr commented on Aug 2, 2023

    @matthiaskrgr
    MemberAuthor

    You can also reproduce this in the rustc repo itself where

    Building compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
       Compiling rustc_errors v0.0.0 (/home/matthias/vcs/github/rust/compiler/rustc_errors)
        Building [==============>          ] 206/322: rustc_errors
    

    will encounter the error with
    RUSTFLAGS="-Zverify-llvm-ir=true -Zvalidate-mir" RUSTC_BOOTSTRAP=1 ./x.py build

  4. lukas-code commented on Aug 2, 2023

    @lukas-code
    Contributor

    Reduced:

    // crate foo
    
    #![feature(type_alias_impl_trait)]
    
    type Tait = impl Sized;
    fn _constrain() -> Tait {}
    
    struct WrapperWithDrop<T>(T);
    impl<T> Drop for WrapperWithDrop<T> {
        fn drop(&mut self) {}
    }
    
    pub struct Foo(WrapperWithDrop<Tait>);
    // crate bar
    
    pub fn drop_foo(_: foo::Foo) {}
    cargo rustc -p bar -- -Z validate-mir

    @rustbot label F-type_alias_impl_trait

  5. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 3, 2023
  6. matthiaskrgr commented on Aug 5, 2023

    @matthiaskrgr
    MemberAuthor

    Found another repro I think:

    use std::backtrace::Backtrace;
    
    const _: fn() = || {
        let backtrace: Backtrace = Backtrace::capture();
    };

    this one bisects to #109075

  7. matthiaskrgr commented on Aug 13, 2023

    @matthiaskrgr
    MemberAuthor
    pub fn foo() {
        std::backtrace::Backtrace::force_capture();
    }
  8. matthiaskrgr commented on Aug 18, 2023

    @matthiaskrgr
    MemberAuthor

    @rustbot prioritize

  9. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 18, 2023
  10. apiraino commented on Aug 18, 2023

    @apiraino
    Contributor

    going to also link #107440 and #107228 as other reports of the same issue

  11. apiraino commented on Aug 18, 2023

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-medium

  12. 2 remaining items

  13. added and removed on Aug 18, 2023
  14. joboet commented on Aug 18, 2023

    @joboet
    Member

    The underlying issue here is an issue with TAIT. #109075 was an implementation-only change simplifying some backtrace code in std that was made under the assumption that TAIT was reliable enough to be used inside std. As it is not user-facing it should be easily revertible. So the question here is whether it is safer to get TAIT working (potentially by reverting #112777?) so it can be used internally or to just hold off on using it until the issue has been resolved, reapplying #109075 once that happens.

    I have no compiler experience, but my initial hunch would be that the library change is preferable for now. I'll get a PR ready until tomorrow, unless someone beats me to it.

  15. added
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    I-compiler-nominatedNominated for discussion during a compiler team meeting.
    on Aug 18, 2023
  16. added
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    and removed
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Aug 18, 2023
  17. compiler-errors commented on Aug 18, 2023

    @compiler-errors
    Contributor

    #112777 should not be reverted. All it does is cause us to now eagerly reveal opaques that were being skipped over during normalization, which means that we're just not hitting this code anymore:

    if (src, dest).has_opaque_types() {
    return true;
    }

    It does not introduce a bug, it just reveals one that already existed.


    I'm gonna use the minimized example (#114375 (comment)) here. What's happening here is that we're generating a drop shim for foo::Foo that looks like:

    fn std::ptr::drop_in_place(_1: *mut Foo) -> () {
        let mut _0: ();
    
        bb0: {
            goto -> bb5;
        }
    
        bb1: {
            return;
        }
    
        bb2 (cleanup): {
            resume;
        }
    
        bb3: {
            goto -> bb1;
        }
    
        bb4 (cleanup): {
            drop(((*_1).0: foo::WrapperWithDrop<()>)) -> [return: bb2, unwind terminate];
        }
    
        bb5: {
            drop(((*_1).0: foo::WrapperWithDrop<()>)) -> [return: bb3, unwind: bb2];
        }
    }
    

    which then tries to validate that (*_1).0: foo::WrapperWithDrop<()>. However, it has type foo::WrapperWithDrop<Tait>, where Tait is a ty::Weak, which does not hit the has_opaque_types code I linked above.

    Before #112777, we'd emit something that looks like:

    fn std::ptr::drop_in_place(_1: *mut Foo) -> () {
        let mut _0: ();
    
        bb0: {
            goto -> bb5;
        }
    
        bb1: {
            return;
        }
    
        bb2 (cleanup): {
            resume;
        }
    
        bb3: {
            goto -> bb1;
        }
    
        bb4 (cleanup): {
            drop(((*_1).0: foo::WrapperWithDrop<Tait::{opaque#0}>)) -> [return: bb2, unwind terminate];
        }
    
        bb5: {
            drop(((*_1).0: foo::WrapperWithDrop<Tait::{opaque#0}>)) -> [return: bb3, unwind: bb2];
        }
    }
    

    which is a field that is incompletely normalized, but does hit the has_opaque_types code above.

  18. joboet commented on Aug 19, 2023

    @joboet
    Member

    Submitted the PR reverting #109075: #114988.

  19. compiler-errors commented on Aug 19, 2023

    @compiler-errors
    Contributor

    #115005 fixes this issue by not considering mir validity on shims until they have been optimized, which uses the reveal-all param-env for that shim.

    This ICE shouldn't be possible to trigger without -Zvalidate-mir, since it has to do with one of the intra-pass mir validations that are only done when that flag is active:

    if validate {
    validate_body(tcx, body, format!("before pass {name}"));
    }

    I don't personally think that #114988 needs to be reverted, either.

  20. compiler-errors commented on Aug 19, 2023

    @compiler-errors
    Contributor

    This was also possible to trigger even before #112777 using an associated type. The test in #115005 exercises this too.

  21. added a commit that references this issue on Aug 22, 2023
    fa38ec0
  22. added a commit that references this issue on Aug 22, 2023
    c469197
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions