Skip to content

ICE: Building async destructor constructor shim is not yet implemented for type: Coroutine #132103

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

Open
matthiaskrgr opened this issue Oct 24, 2024 · 1 comment
Labels
-Zvalidate-mir Unstable option: MIR validation A-async-await Area: Async & Await A-coroutines Area: Coroutines A-destructors Area: Destructors (`Drop`, …) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

//@compile-flags: -Zvalidate-mir --edition=2018 -Zinline-mir=yes
use core::future::{async_drop_in_place, Future};
use core::mem::{self};
use core::pin::pin;
use core::task::{Context, Waker};

async fn test_async_drop<T>(x: T) {
    let mut x = mem::MaybeUninit::new(x);
    pin!(unsafe { async_drop_in_place(x.as_mut_ptr()) });
}

fn main() {
    let waker = Waker::noop();
    let mut cx = Context::from_waker(&waker);

    let fut = pin!(async {
        test_async_drop(test_async_drop(0)).await;
    });
    fut.poll(&mut cx);
}

original:

use core::mem::{self};
use core::pin::{pin};
use core::task::{Context, Waker};
use core::future::{async_drop_in_place, Future};

async fn test_async_drop<T>(x: T) {
    let mut x = mem::MaybeUninit::new(x);
    pin!(unsafe { async_drop_in_place(x.as_mut_ptr()) });
}

fn main() {
    let waker = Waker::noop();
    let mut cx = Context::from_waker(&waker);

    let fut = pin!(async {
        test_async_drop(test_async_drop(0)).await;
    });
    fut.poll(&mut cx);
}

Version information

rustc 1.84.0-nightly (8aca4bab0 2024-10-24)
binary: rustc
commit-hash: 8aca4bab080b2c81065645fc070acca7a060f8a3
commit-date: 2024-10-24
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

Possibly related line of code:

| ty::Param(_)
| ty::Alias(..) => {
bug!("Building async destructor for unexpected type: {self_ty:?}")
}
_ => {
bug!(
"Building async destructor constructor shim is not yet implemented for type: {self_ty:?}"
)
}
}
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zvalidate-mir --edition=2018 -Zinline-mir=yes

Program output

error[E0658]: use of unstable library feature 'async_drop'
 --> /tmp/icemaker_global_tempdir.DLGUrsC6bQJS/rustc_testrunner_tmpdir_reporting.XPxMHGh28ax0/mvce.rs:1:20
  |
1 | use core::future::{async_drop_in_place, Future};
  |                    ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #126482 <https://github.com/rust-lang/rust/issues/126482> for more information
  = help: add `#![feature(async_drop)]` to the crate attributes to enable
  = note: this compiler was built on 2024-10-24; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'async_drop'
 --> /tmp/icemaker_global_tempdir.DLGUrsC6bQJS/rustc_testrunner_tmpdir_reporting.XPxMHGh28ax0/mvce.rs:8:19
  |
8 |     pin!(unsafe { async_drop_in_place(x.as_mut_ptr()) });
  |                   ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #126482 <https://github.com/rust-lang/rust/issues/126482> for more information
  = help: add `#![feature(async_drop)]` to the crate attributes to enable
  = note: this compiler was built on 2024-10-24; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature 'noop_waker'
  --> /tmp/icemaker_global_tempdir.DLGUrsC6bQJS/rustc_testrunner_tmpdir_reporting.XPxMHGh28ax0/mvce.rs:12:17
   |
12 |     let waker = Waker::noop();
   |                 ^^^^^^^^^^^
   |
   = note: see issue #98286 <https://github.com/rust-lang/rust/issues/98286> for more information
   = help: add `#![feature(noop_waker)]` to the crate attributes to enable
   = note: this compiler was built on 2024-10-24; consider upgrading it if it is out of date

error: internal compiler error: compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs:182:17: Building async destructor constructor shim is not yet implemented for type: Coroutine(DefId(0:15 ~ mvce[b792]::test_async_drop::{closure#0}), [i32, (), std::future::ResumeTy, (), (), CoroutineWitness(DefId(0:15 ~ mvce[b792]::test_async_drop::{closure#0}), [i32]), (i32,)])

thread 'rustc' panicked at compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs:182:17:
Box<dyn Any>
stack backtrace:
   0:     0x70ab7668515a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h67a760f142b10089
   1:     0x70ab76e041ca - core::fmt::write::h761a6181051e2338
   2:     0x70ab780aaf11 - std::io::Write::write_fmt::h51dcb9980640e286
   3:     0x70ab76684fb2 - std::sys::backtrace::BacktraceLock::print::h699259bafadc78e2
   4:     0x70ab76687496 - std::panicking::default_hook::{{closure}}::h26f90f180373fe14
   5:     0x70ab766872e0 - std::panicking::default_hook::hc56aa4946c4cfd81
   6:     0x70ab75711a5f - std[154c2b8f5633419d]::panicking::update_hook::<alloc[b3c0c984dc0f1f14]::boxed::Box<rustc_driver_impl[1713c7a502794333]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x70ab76687ba8 - std::panicking::rust_panic_with_hook::hc7e3b32b38224be2
   8:     0x70ab7574b7c1 - std[154c2b8f5633419d]::panicking::begin_panic::<rustc_errors[68da6a21905bba74]::ExplicitBug>::{closure#0}
   9:     0x70ab7573e766 - std[154c2b8f5633419d]::sys::backtrace::__rust_end_short_backtrace::<std[154c2b8f5633419d]::panicking::begin_panic<rustc_errors[68da6a21905bba74]::ExplicitBug>::{closure#0}, !>
  10:     0x70ab75739d69 - std[154c2b8f5633419d]::panicking::begin_panic::<rustc_errors[68da6a21905bba74]::ExplicitBug>
  11:     0x70ab75755331 - <rustc_errors[68da6a21905bba74]::diagnostic::BugAbort as rustc_errors[68da6a21905bba74]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x70ab75dc1ae4 - rustc_middle[7ecdc0b6d8402894]::util::bug::opt_span_bug_fmt::<rustc_span[9923c3b3311dc018]::span_encoding::Span>::{closure#0}
  13:     0x70ab75da7f8a - rustc_middle[7ecdc0b6d8402894]::ty::context::tls::with_opt::<rustc_middle[7ecdc0b6d8402894]::util::bug::opt_span_bug_fmt<rustc_span[9923c3b3311dc018]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x70ab75da7e1b - rustc_middle[7ecdc0b6d8402894]::ty::context::tls::with_context_opt::<rustc_middle[7ecdc0b6d8402894]::ty::context::tls::with_opt<rustc_middle[7ecdc0b6d8402894]::util::bug::opt_span_bug_fmt<rustc_span[9923c3b3311dc018]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x70ab73d738c0 - rustc_middle[7ecdc0b6d8402894]::util::bug::bug_fmt
  16:     0x70ab77834bd5 - rustc_mir_transform[757de5d5b0d4bfad]::shim::make_shim
  17:     0x70ab778317af - rustc_query_impl[5d234f7b7f31cffe]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5d234f7b7f31cffe]::query_impl::mir_shims::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 8usize]>>
  18:     0x70ab7783176f - <rustc_query_impl[5d234f7b7f31cffe]::query_impl::mir_shims::dynamic_query::{closure#2} as core[f763a1f5684efb66]::ops::function::FnOnce<(rustc_middle[7ecdc0b6d8402894]::ty::context::TyCtxt, rustc_middle[7ecdc0b6d8402894]::ty::instance::InstanceKind)>>::call_once
  19:     0x70ab7722dc74 - rustc_query_system[f9c49b141f9e0de3]::query::plumbing::try_execute_query::<rustc_query_impl[5d234f7b7f31cffe]::DynamicConfig<rustc_query_system[f9c49b141f9e0de3]::query::caches::DefaultCache<rustc_middle[7ecdc0b6d8402894]::ty::instance::InstanceKind, rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5d234f7b7f31cffe]::plumbing::QueryCtxt, false>
  20:     0x70ab7722d9cb - rustc_query_impl[5d234f7b7f31cffe]::query_impl::mir_shims::get_query_non_incr::__rust_end_short_backtrace
  21:     0x70ab740dfb45 - <rustc_middle[7ecdc0b6d8402894]::ty::context::TyCtxt>::instance_mir
  22:     0x70ab7781295c - rustc_mir_transform[757de5d5b0d4bfad]::inline::cycle::mir_inliner_callees
  23:     0x70ab77812828 - rustc_query_impl[5d234f7b7f31cffe]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5d234f7b7f31cffe]::query_impl::mir_inliner_callees::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 16usize]>>
  24:     0x70ab778127e7 - <rustc_query_impl[5d234f7b7f31cffe]::query_impl::mir_inliner_callees::dynamic_query::{closure#2} as core[f763a1f5684efb66]::ops::function::FnOnce<(rustc_middle[7ecdc0b6d8402894]::ty::context::TyCtxt, rustc_middle[7ecdc0b6d8402894]::ty::instance::InstanceKind)>>::call_once
  25:     0x70ab7722ceb4 - rustc_query_system[f9c49b141f9e0de3]::query::plumbing::try_execute_query::<rustc_query_impl[5d234f7b7f31cffe]::DynamicConfig<rustc_query_system[f9c49b141f9e0de3]::query::caches::DefaultCache<rustc_middle[7ecdc0b6d8402894]::ty::instance::InstanceKind, rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[5d234f7b7f31cffe]::plumbing::QueryCtxt, false>
  26:     0x70ab7722cbff - rustc_query_impl[5d234f7b7f31cffe]::query_impl::mir_inliner_callees::get_query_non_incr::__rust_end_short_backtrace
  27:     0x70ab77c7ae93 - rustc_mir_transform[757de5d5b0d4bfad]::inline::cycle::mir_callgraph_reachable::process
  28:     0x70ab77c7886a - rustc_mir_transform[757de5d5b0d4bfad]::inline::cycle::mir_callgraph_reachable::process
  29:     0x70ab77c7886a - rustc_mir_transform[757de5d5b0d4bfad]::inline::cycle::mir_callgraph_reachable::process
  30:     0x70ab77c7886a - rustc_mir_transform[757de5d5b0d4bfad]::inline::cycle::mir_callgraph_reachable::process
  31:     0x70ab77c76788 - rustc_mir_transform[757de5d5b0d4bfad]::inline::cycle::mir_callgraph_reachable
  32:     0x70ab77c76629 - rustc_query_impl[5d234f7b7f31cffe]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5d234f7b7f31cffe]::query_impl::mir_callgraph_reachable::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 1usize]>>
  33:     0x70ab77c765eb - <rustc_query_impl[5d234f7b7f31cffe]::query_impl::mir_callgraph_reachable::dynamic_query::{closure#2} as core[f763a1f5684efb66]::ops::function::FnOnce<(rustc_middle[7ecdc0b6d8402894]::ty::context::TyCtxt, (rustc_middle[7ecdc0b6d8402894]::ty::instance::Instance, rustc_span[9923c3b3311dc018]::def_id::LocalDefId))>>::call_once
  34:     0x70ab77c75fa6 - rustc_query_system[f9c49b141f9e0de3]::query::plumbing::try_execute_query::<rustc_query_impl[5d234f7b7f31cffe]::DynamicConfig<rustc_query_system[f9c49b141f9e0de3]::query::caches::DefaultCache<(rustc_middle[7ecdc0b6d8402894]::ty::instance::Instance, rustc_span[9923c3b3311dc018]::def_id::LocalDefId), rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5d234f7b7f31cffe]::plumbing::QueryCtxt, false>
  35:     0x70ab77c75cf4 - rustc_query_impl[5d234f7b7f31cffe]::query_impl::mir_callgraph_reachable::get_query_non_incr::__rust_end_short_backtrace
  36:     0x70ab777ee11d - <rustc_mir_transform[757de5d5b0d4bfad]::inline::Inliner>::try_inlining
  37:     0x70ab7780a42b - <rustc_mir_transform[757de5d5b0d4bfad]::inline::Inliner>::process_blocks
  38:     0x70ab77809937 - <rustc_mir_transform[757de5d5b0d4bfad]::inline::Inline as rustc_mir_transform[757de5d5b0d4bfad]::pass_manager::MirPass>::run_pass
  39:     0x70ab76e0c1cd - rustc_mir_transform[757de5d5b0d4bfad]::pass_manager::run_passes_inner
  40:     0x70ab7780fdae - rustc_mir_transform[757de5d5b0d4bfad]::optimized_mir
  41:     0x70ab7780e65b - rustc_query_impl[5d234f7b7f31cffe]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5d234f7b7f31cffe]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 8usize]>>
  42:     0x70ab76e271ee - rustc_query_system[f9c49b141f9e0de3]::query::plumbing::try_execute_query::<rustc_query_impl[5d234f7b7f31cffe]::DynamicConfig<rustc_query_system[f9c49b141f9e0de3]::query::caches::DefIdCache<rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5d234f7b7f31cffe]::plumbing::QueryCtxt, false>
  43:     0x70ab76e26773 - rustc_query_impl[5d234f7b7f31cffe]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  44:     0x70ab740dfbdf - <rustc_middle[7ecdc0b6d8402894]::ty::context::TyCtxt>::instance_mir
  45:     0x70ab7723328e - rustc_interface[8a226d11e1d62432]::passes::run_required_analyses
  46:     0x70ab77989a9e - rustc_interface[8a226d11e1d62432]::passes::analysis
  47:     0x70ab77989a71 - rustc_query_impl[5d234f7b7f31cffe]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5d234f7b7f31cffe]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 1usize]>>
  48:     0x70ab77d2cbae - rustc_query_system[f9c49b141f9e0de3]::query::plumbing::try_execute_query::<rustc_query_impl[5d234f7b7f31cffe]::DynamicConfig<rustc_query_system[f9c49b141f9e0de3]::query::caches::SingleCache<rustc_middle[7ecdc0b6d8402894]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5d234f7b7f31cffe]::plumbing::QueryCtxt, false>
  49:     0x70ab77d2c88f - rustc_query_impl[5d234f7b7f31cffe]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  50:     0x70ab77bd1eac - rustc_interface[8a226d11e1d62432]::interface::run_compiler::<core[f763a1f5684efb66]::result::Result<(), rustc_span[9923c3b3311dc018]::ErrorGuaranteed>, rustc_driver_impl[1713c7a502794333]::run_compiler::{closure#0}>::{closure#1}
  51:     0x70ab77c47cd4 - std[154c2b8f5633419d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8a226d11e1d62432]::util::run_in_thread_with_globals<rustc_interface[8a226d11e1d62432]::util::run_in_thread_pool_with_globals<rustc_interface[8a226d11e1d62432]::interface::run_compiler<core[f763a1f5684efb66]::result::Result<(), rustc_span[9923c3b3311dc018]::ErrorGuaranteed>, rustc_driver_impl[1713c7a502794333]::run_compiler::{closure#0}>::{closure#1}, core[f763a1f5684efb66]::result::Result<(), rustc_span[9923c3b3311dc018]::ErrorGuaranteed>>::{closure#0}, core[f763a1f5684efb66]::result::Result<(), rustc_span[9923c3b3311dc018]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f763a1f5684efb66]::result::Result<(), rustc_span[9923c3b3311dc018]::ErrorGuaranteed>>
  52:     0x70ab77c480e8 - <<std[154c2b8f5633419d]::thread::Builder>::spawn_unchecked_<rustc_interface[8a226d11e1d62432]::util::run_in_thread_with_globals<rustc_interface[8a226d11e1d62432]::util::run_in_thread_pool_with_globals<rustc_interface[8a226d11e1d62432]::interface::run_compiler<core[f763a1f5684efb66]::result::Result<(), rustc_span[9923c3b3311dc018]::ErrorGuaranteed>, rustc_driver_impl[1713c7a502794333]::run_compiler::{closure#0}>::{closure#1}, core[f763a1f5684efb66]::result::Result<(), rustc_span[9923c3b3311dc018]::ErrorGuaranteed>>::{closure#0}, core[f763a1f5684efb66]::result::Result<(), rustc_span[9923c3b3311dc018]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f763a1f5684efb66]::result::Result<(), rustc_span[9923c3b3311dc018]::ErrorGuaranteed>>::{closure#1} as core[f763a1f5684efb66]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x70ab77c48bab - std::sys::pal::unix::thread::Thread::new::thread_start::hef945dd3992d59fc
  54:     0x70ab71ea339d - <unknown>
  55:     0x70ab71f2849c - <unknown>
  56:                0x0 - <unknown>

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: rustc 1.84.0-nightly (8aca4bab0 2024-10-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z validate-mir -Z inline-mir=yes -Z dump-mir-dir=dir

query stack during panic:
#0 [mir_shims] generating MIR shim for `core::future::async_drop::async_drop_in_place_raw`
#1 [mir_inliner_callees] computing all local function calls in `core::future::async_drop::async_drop_in_place_raw`
end of query stack
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0658`.

@matthiaskrgr matthiaskrgr 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 Oct 24, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 24, 2024
@matthiaskrgr
Copy link
Member Author

according to cargo-bisect-rustc this starts happening with fa72f07 / #129797 but thats probably not it lol

@lolbinarycat lolbinarycat added A-async-await Area: Async & Await A-destructors Area: Destructors (`Drop`, …) A-coroutines Area: Coroutines -Zvalidate-mir Unstable option: MIR validation and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 24, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zvalidate-mir Unstable option: MIR validation A-async-await Area: Async & Await A-coroutines Area: Coroutines A-destructors Area: Destructors (`Drop`, …) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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