Skip to content

Assertion failure: Unexpected captures in ABI-compatible shim for Fn/FnMut implementation of coroutine-closure #127135

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

Closed
AmitDIRTYC0W opened this issue Jun 29, 2024 · 1 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.

Comments

@AmitDIRTYC0W
Copy link

Code

#![feature(async_closure)]

use std::error::Error;

use futures::future::join_all;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
    let dumps = Vec::<()>::new();

    let (ticks_sender, _) = kanal::bounded::<()>(0);

    join_all(
        dumps
            .iter()
            .map(async |_| {
                let _ = ticks_sender.clone();
            })
            .into_iter(),
    )
    .await;

    Ok(())
}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (9c3bc805d 2024-06-27)
binary: rustc
commit-hash: 9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9
commit-date: 2024-06-27
host: x86_64-unknown-linux-musl
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

~//Mmatamm/mmatamm-fetch-min% cargo +nightly build
   Compiling mmatamm-fetch v0.1.0 (/home/user/Mmatamm/mmatamm-fetch-min)
thread 'rustc' panicked at compiler/rustc_mir_transform/src/shim.rs:1036:9:
assertion `left == right` failed
  left: (&'{erased} kanal::Sender<()>,)
 right: ()
Backtrace

   Compiling mmatamm-fetch v0.1.0 (/home/user/Mmatamm/mmatamm-fetch-min)
thread 'rustc' panicked at compiler/rustc_mir_transform/src/shim.rs:1036:9:
assertion `left == right` failed
  left: (&'{erased} kanal::Sender<()>,)
 right: ()
stack backtrace:
   0:     0x7f4945080ce5 - std::backtrace_rs::backtrace::libunwind::trace::h05c50c364cc6c821
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7f4945080ce5 - std::backtrace_rs::backtrace::trace_unsynchronized::h554bc0e08bfc9f13
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4945080ce5 - std::sys::backtrace::_print_fmt::h86764f00281369a2
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:68:5
   3:     0x7f4945080ce5 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4e641c62994794dd
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:44:22
   4:     0x7f49450cd9ab - core::fmt::rt::Argument::fmt::h55cce8387ac75380
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/fmt/rt.rs:165:63
   5:     0x7f49450cd9ab - core::fmt::write::h862fc352e16281b0
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/fmt/mod.rs:1168:21
   6:     0x7f494507618f - std::io::Write::write_fmt::hdd657bffaa4634ac
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/io/mod.rs:1835:15
   7:     0x7f4945080abe - std::sys::backtrace::_print::h2d286f54177eb228
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:47:5
   8:     0x7f4945080abe - std::sys::backtrace::print::h2d374946a832d2c8
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:34:9
   9:     0x7f49450833f9 - std::panicking::default_hook::{{closure}}::h0d9b2f4d96dc17a3
  10:     0x7f494508319c - std::panicking::default_hook::h0442fd1f0f5e3ce4
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/panicking.rs:292:9
  11:     0x7f4945fc49c7 - <alloc[da123ebfcc1bf83c]::boxed::Box<rustc_driver_impl[7d73113946668f05]::install_ice_hook::{closure#0}> as core[50323693079b8a22]::ops::function::Fn<(&dyn for<'a, 'b> core[50323693079b8a22]::ops::function::Fn<(&'a std[50f37666b61fb822]::panic::PanicHookInfo<'b>,), Output = ()> + core[50323693079b8a22]::marker::Send + core[50323693079b8a22]::marker::Sync, &std[50f37666b61fb822]::panic::PanicHookInfo)>>::call
  12:     0x7f4945083c5f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h3709f24897891492
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/alloc/src/boxed.rs:2078:9
  13:     0x7f4945083c5f - std::panicking::rust_panic_with_hook::he83f9908ca3aa17a
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/panicking.rs:804:13
  14:     0x7f4945083887 - std::panicking::begin_panic_handler::{{closure}}::h41c05432f48d2de9
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/panicking.rs:670:13
  15:     0x7f49450811a9 - std::sys::backtrace::__rust_end_short_backtrace::hd8b4f55dad2479aa
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:171:18
  16:     0x7f4945083564 - rust_begin_unwind
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/panicking.rs:661:5
  17:     0x7f4945044163 - core::panicking::panic_fmt::h504cac7e6545ebb2
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/panicking.rs:74:14
  18:     0x7f49450445ce - core::panicking::assert_failed_inner::hb215926d1e0f0eb1
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/panicking.rs:410:17
  19:     0x7f4945cc792f - core[50323693079b8a22]::panicking::assert_failed::<rustc_middle[554f54f0702e273]::ty::Ty, rustc_middle[554f54f0702e273]::ty::Ty>
  20:     0x7f494a2d8d63 - rustc_mir_transform[c715f790cd9eecbb]::shim::make_shim
  21:     0x7f494af507a6 - rustc_query_impl[b2a46b2c886afb91]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b2a46b2c886afb91]::query_impl::mir_shims::dynamic_query::{closure#2}::{closure#0}, rustc_middle[554f54f0702e273]::query::erase::Erased<[u8; 8usize]>>
  22:     0x7f494b0c852e - <rustc_query_impl[b2a46b2c886afb91]::query_impl::mir_shims::dynamic_query::{closure#2} as core[50323693079b8a22]::ops::function::FnOnce<(rustc_middle[554f54f0702e273]::ty::context::TyCtxt, rustc_middle[554f54f0702e273]::ty::instance::InstanceKind)>>::call_once
  23:     0x7f494b245f1a - rustc_query_system[f4766312f97a4e54]::query::plumbing::try_execute_query::<rustc_query_impl[b2a46b2c886afb91]::DynamicConfig<rustc_query_system[f4766312f97a4e54]::query::caches::DefaultCache<rustc_middle[554f54f0702e273]::ty::instance::InstanceKind, rustc_middle[554f54f0702e273]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[b2a46b2c886afb91]::plumbing::QueryCtxt, true>
  24:     0x7f494b16d5bd - rustc_query_impl[b2a46b2c886afb91]::query_impl::mir_shims::get_query_incr::__rust_end_short_backtrace
  25:     0x7f494c2c120f - <rustc_middle[554f54f0702e273]::ty::context::TyCtxt>::instance_mir
  26:     0x7f494bb39b32 - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_of_instance
  27:     0x7f494bb387da - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  28:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  29:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  30:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  31:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  32:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  33:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  34:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  35:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  36:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  37:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  38:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  39:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  40:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  41:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  42:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  43:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  44:     0x7f494bb3947f - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_items_rec
  45:     0x7f494bb4f0db - std[50f37666b61fb822]::panicking::try::<(), core[50323693079b8a22]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[8c0349381b128ed5]::sync::parallel::enabled::par_for_each_in<rustc_middle[554f54f0702e273]::mir::mono::MonoItem, alloc[da123ebfcc1bf83c]::vec::Vec<rustc_middle[554f54f0702e273]::mir::mono::MonoItem>, rustc_monomorphize[98a501fd2ab508e8]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>>
  46:     0x7f494bb65626 - <rustc_data_structures[8c0349381b128ed5]::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures[8c0349381b128ed5]::sync::parallel::enabled::par_for_each_in<rustc_middle[554f54f0702e273]::mir::mono::MonoItem, alloc[da123ebfcc1bf83c]::vec::Vec<rustc_middle[554f54f0702e273]::mir::mono::MonoItem>, rustc_monomorphize[98a501fd2ab508e8]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>
  47:     0x7f494bb7fe05 - <rustc_session[e024c1c3cb6fb710]::session::Session>::time::<(), rustc_monomorphize[98a501fd2ab508e8]::collector::collect_crate_mono_items::{closure#1}>
  48:     0x7f494bb3b791 - rustc_monomorphize[98a501fd2ab508e8]::collector::collect_crate_mono_items
  49:     0x7f494bb41e89 - rustc_monomorphize[98a501fd2ab508e8]::partitioning::collect_and_partition_mono_items
  50:     0x7f494af4f9e6 - rustc_query_impl[b2a46b2c886afb91]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b2a46b2c886afb91]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[554f54f0702e273]::query::erase::Erased<[u8; 24usize]>>
  51:     0x7f494b15029c - <rustc_query_impl[b2a46b2c886afb91]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[50323693079b8a22]::ops::function::FnOnce<(rustc_middle[554f54f0702e273]::ty::context::TyCtxt, ())>>::call_once
  52:     0x7f494b1ea7bb - rustc_query_system[f4766312f97a4e54]::query::plumbing::try_execute_query::<rustc_query_impl[b2a46b2c886afb91]::DynamicConfig<rustc_query_system[f4766312f97a4e54]::query::caches::SingleCache<rustc_middle[554f54f0702e273]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[b2a46b2c886afb91]::plumbing::QueryCtxt, true>
  53:     0x7f494b1859a1 - rustc_query_impl[b2a46b2c886afb91]::query_impl::collect_and_partition_mono_items::get_query_incr::__rust_end_short_backtrace
  54:     0x7f494645c1fa - rustc_codegen_ssa[2e3fbb61cc9534c9]::base::codegen_crate::<rustc_codegen_llvm[83ed650010a9493d]::LlvmCodegenBackend>
  55:     0x7f4946361441 - <rustc_codegen_llvm[83ed650010a9493d]::LlvmCodegenBackend as rustc_codegen_ssa[2e3fbb61cc9534c9]::traits::backend::CodegenBackend>::codegen_crate
  56:     0x7f4946284fc3 - <rustc_session[e024c1c3cb6fb710]::session::Session>::time::<alloc[da123ebfcc1bf83c]::boxed::Box<dyn core[50323693079b8a22]::any::Any>, rustc_interface[deac5c6d0bff0174]::passes::start_codegen::{closure#0}>
  57:     0x7f4946201c3d - rustc_interface[deac5c6d0bff0174]::passes::start_codegen
  58:     0x7f4946310028 - <rustc_middle[554f54f0702e273]::ty::context::GlobalCtxt>::enter::<<rustc_interface[deac5c6d0bff0174]::queries::Queries>::codegen_and_build_linker::{closure#0}, core[50323693079b8a22]::result::Result<rustc_interface[deac5c6d0bff0174]::queries::Linker, rustc_span[58e35cee52347c44]::ErrorGuaranteed>>
  59:     0x7f49462aa63e - <rustc_interface[deac5c6d0bff0174]::queries::Queries>::codegen_and_build_linker
  60:     0x7f49460139b4 - <rustc_interface[deac5c6d0bff0174]::interface::Compiler>::enter::<rustc_driver_impl[7d73113946668f05]::run_compiler::{closure#0}::{closure#1}, core[50323693079b8a22]::result::Result<core[50323693079b8a22]::option::Option<rustc_interface[deac5c6d0bff0174]::queries::Linker>, rustc_span[58e35cee52347c44]::ErrorGuaranteed>>
  61:     0x7f4945fb7cbb - rustc_span[58e35cee52347c44]::create_session_globals_then::<core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>, rustc_interface[deac5c6d0bff0174]::util::run_in_thread_with_globals<rustc_interface[deac5c6d0bff0174]::util::run_in_thread_pool_with_globals<rustc_interface[deac5c6d0bff0174]::interface::run_compiler<core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>, rustc_driver_impl[7d73113946668f05]::run_compiler::{closure#0}>::{closure#1}, core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>>::{closure#0}, core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
  62:     0x7f4945fceab2 - std[50f37666b61fb822]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[deac5c6d0bff0174]::util::run_in_thread_with_globals<rustc_interface[deac5c6d0bff0174]::util::run_in_thread_pool_with_globals<rustc_interface[deac5c6d0bff0174]::interface::run_compiler<core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>, rustc_driver_impl[7d73113946668f05]::run_compiler::{closure#0}>::{closure#1}, core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>>::{closure#0}, core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>>
  63:     0x7f4945fd1bda - <<std[50f37666b61fb822]::thread::Builder>::spawn_unchecked_<rustc_interface[deac5c6d0bff0174]::util::run_in_thread_with_globals<rustc_interface[deac5c6d0bff0174]::util::run_in_thread_pool_with_globals<rustc_interface[deac5c6d0bff0174]::interface::run_compiler<core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>, rustc_driver_impl[7d73113946668f05]::run_compiler::{closure#0}>::{closure#1}, core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>>::{closure#0}, core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[50323693079b8a22]::result::Result<(), rustc_span[58e35cee52347c44]::ErrorGuaranteed>>::{closure#2} as core[50323693079b8a22]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  64:     0x7f494508d76b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7ab3f07cb0ebe863
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/alloc/src/boxed.rs:2064:9
  65:     0x7f494508d76b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf61d026fdda4b90a
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/alloc/src/boxed.rs:2064:9
  66:     0x7f494508d76b - std::sys::pal::unix::thread::Thread::new::thread_start::ha3d2b6ece884ed3a
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/pal/unix/thread.rs:108:17
  67:     0x7f494fd83c0e - start
                               at ./src/thread/pthread_create.c:195:2

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

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 make sure that you have updated to the latest nightly

note: please attach the file at `/home/user/Mmatamm/mmatamm-fetch-min/rustc-ice-2024-06-29T20_51_40-29322.txt` to your bug report

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

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

query stack during panic:
#0 [mir_shims] generating MIR shim for `main::{closure#0}::{closure#0}`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `mmatamm-fetch` (bin "mmatamm-fetch")

@AmitDIRTYC0W AmitDIRTYC0W 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 Jun 29, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 29, 2024
@compiler-errors
Copy link
Member

Duplicate of #127012. I'm putting up a fix soon.

@compiler-errors compiler-errors closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 30, 2024
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

4 participants