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

internal compiler error when copying borrow of leaked Box into async move closure for FutureExt::then #123334

Closed
Pr0methean opened this issue Mar 28, 2024 · 13 comments
Assignees
Labels
A-async-await Area: Async & Await A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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

@Pr0methean
Copy link

Summary

Reproducer

I tried to run cd main && cargo clippy against Pr0methean/OcHd-RustBuild@5a9dee8. The code near where the error arose is:

        let max_colors = Box::leak(Box::new(pixels + 1));
        let image_task = self.add_to(ctx, side_length);
        let wrapped_task = task.then(async move |mut uncapped: SimpleArcow<ColorDescription>| {
            uncapped.cap_indexed(*max_colors, image_task).await;
            uncapped
        })
        .boxed()
        .shared();

The error I get is

error: internal compiler error: broken MIR in DefId(0:642 ~ ochd[a7c9]::image_tasks::task_spec::{impl#15}::get_color_description_task::{closure#6}) (bb0[0]): equate_normalized_input_or_output: `Coroutine(DefId(0:643 ~ ochd[a7c9]::image_tasks::task_spec::{impl#15}::get_color_description_task::{closure#6}::{closure#0}), [i32, std::future::ResumeTy, (), image_tasks::cloneable::Arcow<'?2, image_tasks::task_spec::ColorDescription, image_tasks::task_spec::ColorDescription>, CoroutineWitness(DefId(0:643 ~ ochd[a7c9]::image_tasks::task_spec::{impl#15}::get_color_description_task::{closure#6}::{closure#0}), []), (image_tasks::cloneable::Arcow<'?1, image_tasks::task_spec::ColorDescription, image_tasks::task_spec::ColorDescription>, &'?3 mut usize, futures_util::future::Shared<std::pin::Pin<std::boxed::Box<dyn [Binder(Trait(futures_util::Future), []), Binder(Projection(ExistentialProjection { def_id: DefId(2:44307 ~ core[3b7f]::future::future::Future::Output), args: [], term: Term::Ty(image_tasks::cloneable::Arcow<'?4, image_tasks::MaybeFromPool<resvg::tiny_skia::Pixmap>, image_tasks::MaybeFromPool<resvg::tiny_skia::Pixmap>>) }), []), Binder(AutoTrait(DefId(2:31925 ~ core[3b7f]::marker::Send)), [])] + '?5, std::alloc::Global>>>)])==Coroutine(DefId(0:643 ~ ochd[a7c9]::image_tasks::task_spec::{impl#15}::get_color_description_task::{closure#6}::{closure#0}), [i32, std::future::ResumeTy, (), image_tasks::cloneable::Arcow<'?20, image_tasks::task_spec::ColorDescription, image_tasks::task_spec::ColorDescription>, CoroutineWitness(DefId(0:643 ~ ochd[a7c9]::image_tasks::task_spec::{impl#15}::get_color_description_task::{closure#6}::{closure#0}), []), (image_tasks::cloneable::Arcow<'?21, image_tasks::task_spec::ColorDescription, image_tasks::task_spec::ColorDescription>, &'?22 usize, futures_util::future::Shared<std::pin::Pin<std::boxed::Box<dyn [Binder(Trait(futures_util::Future), []), Binder(Projection(ExistentialProjection { def_id: DefId(2:44307 ~ core[3b7f]::future::future::Future::Output), args: [], term: Term::Ty(image_tasks::cloneable::Arcow<'?23, image_tasks::MaybeFromPool<resvg::tiny_skia::Pixmap>, image_tasks::MaybeFromPool<resvg::tiny_skia::Pixmap>>) }), []), Binder(AutoTrait(DefId(2:31925 ~ core[3b7f]::marker::Send)), [])] + '?24, std::alloc::Global>>>)])` failed with `NoSolution`
    --> src/image_tasks/task_spec.rs:1159:38
     |
1159 |           let wrapped_task = task.then(async move |mut uncapped: SimpleArcow<ColorDescription>| {
     |  ______________________________________^
1160 | |             uncapped.cap_indexed(*max_colors, image_task).await;
1161 | |             uncapped
1162 | |         })
     | |_________^
     |
note: delayed at compiler/rustc_borrowck/src/type_check/input_output.rs:213:17
         0: std::backtrace::Backtrace::create
         1: std::backtrace::Backtrace::capture
         2: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         3: <rustc_errors::DiagCtxt>::emit_diagnostic
         4: <rustc_errors::diagnostic::DiagnosticBuilder>::emit_producing_error_guaranteed
         5: <rustc_borrowck::type_check::TypeChecker>::equate_normalized_input_or_output
         6: rustc_borrowck::type_check::type_check
         7: rustc_borrowck::nll::compute_regions
         8: rustc_borrowck::do_mir_borrowck
         9: rustc_borrowck::mir_borrowck
        10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        11: <rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
        12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        13: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
        14: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>>
        15: <rustc_borrowck::type_check::TypeChecker>::prove_closure_bounds
        16: <rustc_borrowck::type_check::TypeChecker>::check_rvalue
        17: <rustc_borrowck::type_check::TypeChecker>::typeck_mir
        18: rustc_borrowck::type_check::type_check
        19: rustc_borrowck::nll::compute_regions
        20: rustc_borrowck::do_mir_borrowck
        21: rustc_borrowck::mir_borrowck
        22: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        23: <rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
        24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        25: rustc_query_impl::query_impl::mir_borrowck::get_query_incr::__rust_end_short_backtrace
        26: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_interface::passes::analysis::{closure#1}::{closure#0}>::{closure#0}
        27: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures::sync::parallel::enabled::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#1}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
        28: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#1}>
        29: rustc_interface::passes::analysis
        30: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        31: <rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, ())>>::call_once
        32: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
        33: rustc_query_impl::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
        34: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        35: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
        36: 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#0}>::{closure#0}::{closure#0}>
        37: rustc_span::create_session_globals_then::<core::result::Result<(), rustc_span::ErrorGuaranteed>, 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#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}>
        38: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<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#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
        39: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<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#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{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}
        40: std::sys::pal::unix::thread::Thread::new::thread_start
        41: __pthread_start
    --> src/image_tasks/task_spec.rs:1159:38
     |
1159 |           let wrapped_task = task.then(async move |mut uncapped: SimpleArcow<ColorDescription>| {
     |  ______________________________________^
1160 | |             uncapped.cap_indexed(*max_colors, image_task).await;
1161 | |             uncapped
1162 | |         })
     | |_________^

Version

hennickc@f8ffc25e7f6e main % rustc -Vv
rustc 1.78.0-nightly (ef324565d 2024-02-27)
binary: rustc
commit-hash: ef324565d071c6d7e2477a195648549e33d6a465
commit-date: 2024-02-27
host: x86_64-apple-darwin
release: 1.78.0-nightly
LLVM version: 18.1.0

Reproducer

I tried this code:

<code>

I expected to see this happen:

Instead, this happened:

Version

No response

Additional Labels

No response

@Pr0methean Pr0methean added the C-bug Category: This is a bug. label Mar 28, 2024
@Pr0methean
Copy link
Author

Pr0methean commented Mar 28, 2024

BTW: I also consider it a bug that I couldn't simply move pixels into the closure without Box::new or Box::leak, since it's of type usize and therefore Copy. Another similar bug seems to be happening a short distance above, which I worked around using Arc::new:

                let bg_task = background.get_color_description_task(ctx);
                let fg_task = foreground.get_color_description_task(ctx);
                let bg_and_fg = join_all([bg_task, fg_task]);
                bg_and_fg.then(async move |mut bg_and_fg: Vec<SimpleArcow<ColorDescription>>| {
                    let fg = bg_and_fg.pop().unwrap();
                    let bg = bg_and_fg.pop().unwrap();
                    let max_colors = Arc::new(pixels + 1);
                    Arcow::from_owned(fg
                        .stack_on(&bg, *max_colors))
                }).boxed()

@Pr0methean Pr0methean changed the title internal compiler error when copying variable into async move closure internal compiler error when copying borrow of leaked Box into async move closure Mar 28, 2024
@Pr0methean Pr0methean changed the title internal compiler error when copying borrow of leaked Box into async move closure internal compiler error when copying borrow of leaked Box into async move closure for FutureExt::then Mar 28, 2024
@Pr0methean
Copy link
Author

Confirmed that this also happens on the latest nightly version:

rustc 1.79.0-nightly (c9f8f3438 2024-03-27)
binary: rustc
commit-hash: c9f8f3438a8134a413aa5d4903e0196e44e37bbc
commit-date: 2024-03-27
host: x86_64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.2

@y21
Copy link
Member

y21 commented Mar 28, 2024

@Pr0methean this looks more like a bug in the compiler rather than clippy, does this happen with cargo check too? Would like confirmation before moving it it over.

@y21 y21 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 28, 2024
@Pr0methean
Copy link
Author

Yes, it does happen with cargo check; output is attached.
cargo check errors.txt

@y21 y21 transferred this issue from rust-lang/rust-clippy Apr 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 1, 2024
@saethlin saethlin added E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-async-await Area: Async & Await and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 9, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Apr 9, 2024

On (nightly rustc 2024-04-08):

backtrace
thread 'rustc' panicked at compiler/rustc_mir_transform/src/coroutine/by_move_body.rs:192:21:
assertion `left != right` failed: `FnOnce` coroutine-closures return coroutines that capture from their body; it will always result in a borrowck error!
  left: FnOnce
 right: FnOnce
stack backtrace:
   0:     0xe81ae47a8208 - std::backtrace_rs::backtrace::libunwind::trace::haa291e613b0120e3
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0xe81ae47a8208 - std::backtrace_rs::backtrace::trace_unsynchronized::hd6058b9271b37498
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0xe81ae47a8208 - std::sys_common::backtrace::_print_fmt::hab025aa7de1873e2
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/sys_common/backtrace.rs:68:5
   3:     0xe81ae47a8208 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h00f983297fbc372e
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/sys_common/backtrace.rs:44:22
   4:     0xe81ae47f2568 - core::fmt::rt::Argument::fmt::he332d767a258e538
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/core/src/fmt/rt.rs:142:9
   5:     0xe81ae47f2568 - core::fmt::write::h417272ffa9510e5f
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/core/src/fmt/mod.rs:1153:17
   6:     0xe81ae479d504 - std::io::Write::write_fmt::haf2496ce6ac2f7bb
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/io/mod.rs:1843:15
   7:     0xe81ae47a8050 - std::sys_common::backtrace::_print::haa922589910f85f9
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/sys_common/backtrace.rs:47:5
   8:     0xe81ae47a8050 - std::sys_common::backtrace::print::he9bfbde48db631e1
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/sys_common/backtrace.rs:34:9
   9:     0xe81ae47aa9a0 - std::panicking::default_hook::{{closure}}::h8c27ba0a61bca9ff
  10:     0xe81ae47aa608 - std::panicking::default_hook::h6ed61f1bb7bde7e3
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/panicking.rs:291:9
  11:     0xe81ae545d6b4 - <alloc[203ad6fa846289de]::boxed::Box<rustc_driver_impl[b215e998407d5517]::install_ice_hook::{closure#0}> as core[d6a9a146ef1a13a7]::ops::function::Fn<(&dyn for<'a, 'b> core[d6a9a146ef1a13a7]::ops::function::Fn<(&'a core[d6a9a146ef1a13a7]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[d6a9a146ef1a13a7]::marker::Sync + core[d6a9a146ef1a13a7]::marker::Send, &core[d6a9a146ef1a13a7]::panic::panic_info::PanicInfo)>>::call
  12:     0xe81ae47ab00c - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7ff12980babc8be9
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/alloc/src/boxed.rs:2032:9
  13:     0xe81ae47ab00c - std::panicking::rust_panic_with_hook::h8b4f2ee87bc8615c
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/panicking.rs:792:13
  14:     0xe81ae47aadd0 - std::panicking::begin_panic_handler::{{closure}}::h8079581052c72851
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/panicking.rs:657:13
  15:     0xe81ae47a86f4 - std::sys_common::backtrace::__rust_end_short_backtrace::h574e6633c80ec618
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/sys_common/backtrace.rs:171:18
  16:     0xe81ae47aab40 - rust_begin_unwind
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/panicking.rs:645:5
  17:     0xe81ae477369c - core::panicking::panic_fmt::h00c8b86dc45668ae
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/core/src/panicking.rs:72:14
  18:     0xe81ae4773a50 - core::panicking::assert_failed_inner::h88c6ee574af04089
  19:     0xe81ae516dbd4 - core[d6a9a146ef1a13a7]::panicking::assert_failed::<rustc_type_ir[dac4ffe821ca126f]::ClosureKind, rustc_type_ir[dac4ffe821ca126f]::ClosureKind>
  20:     0xe81ae8a2dc24 - <rustc_mir_transform[31f0cbefe9fdfeb6]::coroutine::by_move_body::ByMoveBody as rustc_middle[ef36aff4fb226d22]::mir::MirPass>::run_pass
  21:     0xe81ae8a2bb10 - rustc_mir_transform[31f0cbefe9fdfeb6]::pass_manager::run_passes_inner
  22:     0xe81ae89504d0 - rustc_mir_transform[31f0cbefe9fdfeb6]::mir_built
  23:     0xe81ae9301834 - rustc_query_impl[574f4dddc2b33a10]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[574f4dddc2b33a10]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef36aff4fb226d22]::query::erase::Erased<[u8; 8usize]>>
  24:     0xe81ae938cad0 - <rustc_query_impl[574f4dddc2b33a10]::query_impl::mir_built::dynamic_query::{closure#2} as core[d6a9a146ef1a13a7]::ops::function::FnOnce<(rustc_middle[ef36aff4fb226d22]::ty::context::TyCtxt, rustc_span[4aae7fa44f1362f6]::def_id::LocalDefId)>>::call_once
  25:     0xe81ae95e3d98 - rustc_query_system[e3defdec8e5cafcb]::query::plumbing::try_execute_query::<rustc_query_impl[574f4dddc2b33a10]::DynamicConfig<rustc_query_system[e3defdec8e5cafcb]::query::caches::VecCache<rustc_span[4aae7fa44f1362f6]::def_id::LocalDefId, rustc_middle[ef36aff4fb226d22]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[574f4dddc2b33a10]::plumbing::QueryCtxt, true>
  26:     0xe81ae94b592c - rustc_query_impl[574f4dddc2b33a10]::query_impl::mir_built::get_query_incr::__rust_end_short_backtrace
  27:     0xe81ae8fa6804 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor>::visit_inner_body
  28:     0xe81ae8fa7840 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  29:     0xe81ae8fa7998 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  30:     0xe81ae8fa6924 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor>::visit_inner_body
  31:     0xe81ae8fa7840 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  32:     0xe81ae8fa7998 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  33:     0xe81ae8ff4860 - rustc_middle[ef36aff4fb226d22]::thir::visit::walk_expr::<rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor>
  34:     0xe81ae8fa79d8 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  35:     0xe81ae8fa7998 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  36:     0xe81ae8ff4860 - rustc_middle[ef36aff4fb226d22]::thir::visit::walk_expr::<rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor>
  37:     0xe81ae8fa79d8 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  38:     0xe81ae8fa7998 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  39:     0xe81ae8ff4860 - rustc_middle[ef36aff4fb226d22]::thir::visit::walk_expr::<rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor>
  40:     0xe81ae8fa79d8 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  41:     0xe81ae8fa7998 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  42:     0xe81ae8ff6044 - rustc_middle[ef36aff4fb226d22]::thir::visit::walk_stmt::<rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor>
  43:     0xe81ae8fa6ce4 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_block
  44:     0xe81ae8fa79d8 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  45:     0xe81ae8fa7998 - <rustc_mir_build[1c707e1349c5b631]::check_unsafety::UnsafetyVisitor as rustc_middle[ef36aff4fb226d22]::thir::visit::Visitor>::visit_expr
  46:     0xe81ae8fa7d90 - rustc_mir_build[1c707e1349c5b631]::check_unsafety::check_unsafety
  47:     0xe81ae92fca90 - rustc_query_impl[574f4dddc2b33a10]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[574f4dddc2b33a10]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef36aff4fb226d22]::query::erase::Erased<[u8; 0usize]>>
  48:     0xe81ae9481310 - <rustc_query_impl[574f4dddc2b33a10]::query_impl::check_unsafety::dynamic_query::{closure#2} as core[d6a9a146ef1a13a7]::ops::function::FnOnce<(rustc_middle[ef36aff4fb226d22]::ty::context::TyCtxt, rustc_span[4aae7fa44f1362f6]::def_id::LocalDefId)>>::call_once
  49:     0xe81ae95d7918 - rustc_query_system[e3defdec8e5cafcb]::query::plumbing::try_execute_query::<rustc_query_impl[574f4dddc2b33a10]::DynamicConfig<rustc_query_system[e3defdec8e5cafcb]::query::caches::VecCache<rustc_span[4aae7fa44f1362f6]::def_id::LocalDefId, rustc_middle[ef36aff4fb226d22]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[574f4dddc2b33a10]::plumbing::QueryCtxt, true>
  50:     0xe81ae93408a0 - rustc_query_impl[574f4dddc2b33a10]::query_impl::check_unsafety::get_query_incr::__rust_end_short_backtrace
  51:     0xe81ae55f8724 - <rustc_middle[ef36aff4fb226d22]::hir::map::Map>::par_body_owners::<rustc_interface[89d48df1a4a89fe2]::passes::analysis::{closure#1}::{closure#0}>::{closure#0}
  52:     0xe81ae5650bbc - <rustc_data_structures[d01047594bd6701f]::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures[d01047594bd6701f]::sync::parallel::enabled::par_for_each_in<&rustc_span[4aae7fa44f1362f6]::def_id::LocalDefId, &[rustc_span[4aae7fa44f1362f6]::def_id::LocalDefId], <rustc_middle[ef36aff4fb226d22]::hir::map::Map>::par_body_owners<rustc_interface[89d48df1a4a89fe2]::passes::analysis::{closure#1}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  53:     0xe81ae55ea3a8 - <rustc_session[1c938199b9633600]::session::Session>::time::<(), rustc_interface[89d48df1a4a89fe2]::passes::analysis::{closure#1}>
  54:     0xe81ae5617a60 - rustc_interface[89d48df1a4a89fe2]::passes::analysis
  55:     0xe81ae9301484 - rustc_query_impl[574f4dddc2b33a10]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[574f4dddc2b33a10]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef36aff4fb226d22]::query::erase::Erased<[u8; 1usize]>>
  56:     0xe81ae94719e4 - <rustc_query_impl[574f4dddc2b33a10]::query_impl::analysis::dynamic_query::{closure#2} as core[d6a9a146ef1a13a7]::ops::function::FnOnce<(rustc_middle[ef36aff4fb226d22]::ty::context::TyCtxt, ())>>::call_once
  57:     0xe81ae955ce60 - rustc_query_system[e3defdec8e5cafcb]::query::plumbing::try_execute_query::<rustc_query_impl[574f4dddc2b33a10]::DynamicConfig<rustc_query_system[e3defdec8e5cafcb]::query::caches::SingleCache<rustc_middle[ef36aff4fb226d22]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[574f4dddc2b33a10]::plumbing::QueryCtxt, true>
  58:     0xe81ae94b47c4 - rustc_query_impl[574f4dddc2b33a10]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  59:     0xe81ae53d26f8 - <rustc_interface[89d48df1a4a89fe2]::queries::QueryResult<&rustc_middle[ef36aff4fb226d22]::ty::context::GlobalCtxt>>::enter::<core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>, rustc_driver_impl[b215e998407d5517]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  60:     0xe81ae5400f50 - <rustc_interface[89d48df1a4a89fe2]::interface::Compiler>::enter::<rustc_driver_impl[b215e998407d5517]::run_compiler::{closure#0}::{closure#1}, core[d6a9a146ef1a13a7]::result::Result<core[d6a9a146ef1a13a7]::option::Option<rustc_interface[89d48df1a4a89fe2]::queries::Linker>, rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>
  61:     0xe81ae5416f44 - rustc_span[4aae7fa44f1362f6]::set_source_map::<core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>, rustc_interface[89d48df1a4a89fe2]::interface::run_compiler<core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>, rustc_driver_impl[b215e998407d5517]::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
  62:     0xe81ae53f62c4 - <scoped_tls[e003357a6e5d5279]::ScopedKey<rustc_span[4aae7fa44f1362f6]::SessionGlobals>>::set::<rustc_interface[89d48df1a4a89fe2]::util::run_in_thread_with_globals<rustc_interface[89d48df1a4a89fe2]::util::run_in_thread_pool_with_globals<rustc_interface[89d48df1a4a89fe2]::interface::run_compiler<core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>, rustc_driver_impl[b215e998407d5517]::run_compiler::{closure#0}>::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>
  63:     0xe81ae54174f0 - rustc_span[4aae7fa44f1362f6]::create_session_globals_then::<core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>, rustc_interface[89d48df1a4a89fe2]::util::run_in_thread_with_globals<rustc_interface[89d48df1a4a89fe2]::util::run_in_thread_pool_with_globals<rustc_interface[89d48df1a4a89fe2]::interface::run_compiler<core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>, rustc_driver_impl[b215e998407d5517]::run_compiler::{closure#0}>::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
  64:     0xe81ae53ce564 - std[187a877501788208]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[89d48df1a4a89fe2]::util::run_in_thread_with_globals<rustc_interface[89d48df1a4a89fe2]::util::run_in_thread_pool_with_globals<rustc_interface[89d48df1a4a89fe2]::interface::run_compiler<core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>, rustc_driver_impl[b215e998407d5517]::run_compiler::{closure#0}>::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>
  65:     0xe81ae53fe9e8 - <<std[187a877501788208]::thread::Builder>::spawn_unchecked_<rustc_interface[89d48df1a4a89fe2]::util::run_in_thread_with_globals<rustc_interface[89d48df1a4a89fe2]::util::run_in_thread_pool_with_globals<rustc_interface[89d48df1a4a89fe2]::interface::run_compiler<core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>, rustc_driver_impl[b215e998407d5517]::run_compiler::{closure#0}>::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d6a9a146ef1a13a7]::result::Result<(), rustc_span[4aae7fa44f1362f6]::ErrorGuaranteed>>::{closure#1} as core[d6a9a146ef1a13a7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  66:     0xe81ae47b4270 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9d8edcb79d66332d
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/alloc/src/boxed.rs:2018:9
  67:     0xe81ae47b4270 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h67f37f60236e01b2
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/alloc/src/boxed.rs:2018:9
  68:     0xe81ae47b4270 - std::sys::pal::unix::thread::Thread::new::thread_start::h57680dfe5e880803
                               at /rustc/ab5bda1aa70f707014e2e691e43bc37a8819252a/library/std/src/sys/pal/unix/thread.rs:108:17
  69:     0xe81ae450d5c8 - start_thread
                               at ./nptl/pthread_create.c:442:8
  70:     0xe81ae4575edc - thread_start
                               at ./misc/../sysdeps/unix/sysv/linux/aarch64/clone.S:79
  71:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: it seems that this compiler `1.79.0-nightly (ab5bda1aa 2024-04-08)` is outdated, a newer nightly should have been released in the meantime
  |
  = note: please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
  = note: if the problem still persists, we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: please attach the file at `/home/gh-jieyouxu/OcHd-RustBuild/main/rustc-ice-2024-04-09T15_58_57-93033.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [mir_built] building MIR for `image_tasks::task_spec::<impl at src/image_tasks/task_spec.rs:1028:1: 1028:22>::get_color_description_task::{closure#6}::{closure#0}`
#1 [check_unsafety] unsafety-checking `image_tasks::task_spec::<impl at src/image_tasks/task_spec.rs:1028:1: 1028:22>::get_color_description_task`
#2 [analysis] running analysis passes on this crate
end of query stack
note: Clippy version: clippy 0.1.79 (ab5bda1a 2024-04-08)

@jieyouxu jieyouxu added the A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Apr 9, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Apr 9, 2024

searched nightlies: from nightly-2024-01-01 to nightly-2024-02-27
regressed nightly: nightly-2024-02-11
searched commit range: d44e3b9...6cc4843
regressed commit: 757b8ef

bisected with cargo-bisect-rustc v0.6.8

Host triple: aarch64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2024-01-01 --end=2024-02-27 --regress=ice --script ./test.sh

@jieyouxu
Copy link
Member

jieyouxu commented Apr 9, 2024

#120712 cc @compiler-errors

@jieyouxu jieyouxu added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example and removed E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc labels Apr 9, 2024
@traviscross
Copy link
Contributor

@rustbot labels +AsyncAwait-Triaged

We discussed this in async triage.

@Pr0methean: Thanks for linking to a repo here. Might you be able to help narrow this down to a smaller reproducible test case? That would definitely help us to make progress here.

@rustbot rustbot added the AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. label May 6, 2024
@brownie-in-motion
Copy link

brownie-in-motion commented May 11, 2024

tried narrowing it down and got here. is this the same bug?

#![feature(async_closure)]

fn f(x: ()) {
    async move |_| { x };
}

looks like this is mentioned in #123901

@Pr0methean
Copy link
Author

The error message is different ("broken MIR in DefId" instead of "leftover child captures?"), but it may be related.

@compiler-errors
Copy link
Member

Yeah, it's the same problem.

@compiler-errors compiler-errors self-assigned this May 11, 2024
@compiler-errors
Copy link
Member

This will likely be fixed when I rebase #124902.

@compiler-errors
Copy link
Member

pretty sure this is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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

8 participants