rustc_codegen_cranelift icon indicating copy to clipboard operation
rustc_codegen_cranelift copied to clipboard

ICE `ArgAbi left behind`

Open matthiaskrgr opened this issue 6 months ago • 2 comments

[31mICE[0m: Rustc ./a.rs '--edition=2024 -Zcodegen-backend=cranelift -Clink-dead-code=true -Zcrate-attr=feature(async_drop) -Zcrate-attr=feature(gen_blocks) -ooutputfile -Zdump-mir-dir=dir' 'thread 'rustc' ($TID) panicked at compiler/rustc_codegen_cranelift/src/abi/mod.rs:299:5: 'ArgAbi left behind'', 'thread 'rustc' ($TID) panicked at compiler/rustc_codegen_cranelift/src/abi/mod.rs:299:5: 'ArgAbi left behind'' File: /tmp/im/a.rs -->

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024 -Zcodegen-backend=cranelift -Clink-dead-code=true
#![feature(async_drop)]
#![feature(gen_blocks)]



fn main() {
    let _ = async {
        let mut gn = gen {
        yield 1;
        2.yield;
    };
        
    };
}

original:

//@ incremental
//@ edition:2021

fn main() {
    let _ = async {
        let mut gn = gen {
        yield 1;
        2.yield;
    };
        //~^ ERROR `[(); _]` is not a future
    };
}

Version information

rustc 1.91.0-nightly (8e3710ef3 2025-08-21)
binary: rustc
commit-hash: 8e3710ef31a0b2cdf5a1c2f3929b7735d1e28c20
commit-date: 2025-08-21
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0

Possibly related line of code: https://github.com/rust-lang/rust/blob/8e3710ef31a0b2cdf5a1c2f3929b7735d1e28c20/compiler/rustc_codegen_cranelift/src/abi/mod.rs#L293-L305

Command: /home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024 -Zcodegen-backend=cranelift -Clink-dead-code=true -Zcrate-attr=feature(async_drop) -Zcrate-attr=feature(gen_blocks)

Program output

warning: the feature `async_drop` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(async_drop)]
  |            ^^^^^^^^^^
  |
  = note: see issue #126482 <https://github.com/rust-lang/rust/issues/126482> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: unused variable: `gn`
 --> /tmp/icemaker_global_tempdir.XM6ODE5Hjm0Y/rustc_testrunner_tmpdir_reporting.12FJUATdHBlM/mvce.rs:6:17
  |
6 |         let mut gn = gen {
  |                 ^^ help: if this is intentional, prefix it with an underscore: `_gn`
  |
  = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: variable does not need to be mutable
 --> /tmp/icemaker_global_tempdir.XM6ODE5Hjm0Y/rustc_testrunner_tmpdir_reporting.12FJUATdHBlM/mvce.rs:6:13
  |
6 |         let mut gn = gen {
  |             ----^^
  |             |
  |             help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` (part of `#[warn(unused)]`) on by default


thread 'rustc' (29598) panicked at compiler/rustc_codegen_cranelift/src/abi/mod.rs:299:5:
ArgAbi left behind
stack backtrace:
   0:     0x7fca4022f453 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h29956387916c7786
   1:     0x7fca40a019d8 - core::fmt::write::hc643e33fb3701c04
   2:     0x7fca40219d23 - std::io::Write::write_fmt::hd8aafd7e0cfa4df0
   3:     0x7fca4022ee02 - std::sys::backtrace::BacktraceLock::print::h7b608780239e41bb
   4:     0x7fca4020fe8e - std::panicking::default_hook::{{closure}}::hb985d7a9c8441027
   5:     0x7fca4020f9b8 - std::panicking::default_hook::h21dd4ceb358d35d5
   6:     0x7fca3f283575 - std[7bbd1c520933e2ca]::panicking::update_hook::<alloc[d048b985160d5cb3]::boxed::Box<rustc_driver_impl[43f25b9ba173297b]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7fca4020f784 - std::panicking::panic_with_hook::h9e10def7ecb801dd
   8:     0x7fca4022f226 - std::panicking::panic_handler::{{closure}}::hcae2f26048275696
   9:     0x7fca4022f1b9 - std::sys::backtrace::__rust_end_short_backtrace::h391fe1ff395ba1e0
  10:     0x7fca4020f8ed - __rustc[27a96dd388c4db29]::rust_begin_unwind
  11:     0x7fca3c8d9840 - core::panicking::panic_fmt::hae068153d2f804a4
  12:     0x7fca2ea3169f - rustc_codegen_cranelift[72d6c50d52a4b85d]::base::codegen_fn_body
  13:     0x7fca2ea51409 - rustc_codegen_cranelift[72d6c50d52a4b85d]::driver::aot::codegen_cgu_content
  14:     0x7fca2ea5e4fc - rustc_codegen_cranelift[72d6c50d52a4b85d]::driver::aot::module_codegen
  15:     0x7fca2eaa9ad9 - rustc_codegen_cranelift[72d6c50d52a4b85d]::driver::aot::run_aot::{closure#3}::{closure#0}
  16:     0x7fca2ea16c89 - <core[944e8f57fc60541e]::iter::adapters::filter_map::FilterMap<alloc[d048b985160d5cb3]::vec::into_iter::IntoIter<(usize, &rustc_middle[984f359684f14d51]::mir::mono::CodegenUnit)>, rustc_data_structures[1992400ef1c04f10]::sync::parallel::par_map<(usize, &rustc_middle[984f359684f14d51]::mir::mono::CodegenUnit), alloc[d048b985160d5cb3]::vec::Vec<(usize, &rustc_middle[984f359684f14d51]::mir::mono::CodegenUnit)>, rustc_data_structures[1992400ef1c04f10]::marker::IntoDynSyncSend<rustc_codegen_cranelift[72d6c50d52a4b85d]::driver::aot::OngoingModuleCodegen>, alloc[d048b985160d5cb3]::vec::Vec<rustc_data_structures[1992400ef1c04f10]::marker::IntoDynSyncSend<rustc_codegen_cranelift[72d6c50d52a4b85d]::driver::aot::OngoingModuleCodegen>>, rustc_codegen_cranelift[72d6c50d52a4b85d]::driver::aot::run_aot::{closure#3}::{closure#0}>::{closure#0}::{closure#3}> as core[944e8f57fc60541e]::iter::traits::iterator::Iterator>::next
  17:     0x7fca2ea59413 - rustc_codegen_cranelift[72d6c50d52a4b85d]::driver::aot::run_aot
  18:     0x7fca2ea7139e - <rustc_codegen_cranelift[72d6c50d52a4b85d]::CraneliftCodegenBackend as rustc_codegen_ssa[8c7a150851651b0c]::traits::backend::CodegenBackend>::codegen_crate
  19:     0x7fca41dacd30 - <rustc_interface[7f26a336caf35539]::queries::Linker>::codegen_and_build_linker
  20:     0x7fca41daa8bc - rustc_interface[7f26a336caf35539]::passes::create_and_enter_global_ctxt::<core[944e8f57fc60541e]::option::Option<rustc_interface[7f26a336caf35539]::queries::Linker>, rustc_driver_impl[43f25b9ba173297b]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  21:     0x7fca41bb8fdf - rustc_interface[7f26a336caf35539]::interface::run_compiler::<(), rustc_driver_impl[43f25b9ba173297b]::run_compiler::{closure#0}>::{closure#1}
  22:     0x7fca41b2c638 - std[7bbd1c520933e2ca]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[7f26a336caf35539]::util::run_in_thread_with_globals<rustc_interface[7f26a336caf35539]::util::run_in_thread_pool_with_globals<rustc_interface[7f26a336caf35539]::interface::run_compiler<(), rustc_driver_impl[43f25b9ba173297b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  23:     0x7fca41b2c31c - <<std[7bbd1c520933e2ca]::thread::Builder>::spawn_unchecked_<rustc_interface[7f26a336caf35539]::util::run_in_thread_with_globals<rustc_interface[7f26a336caf35539]::util::run_in_thread_pool_with_globals<rustc_interface[7f26a336caf35539]::interface::run_compiler<(), rustc_driver_impl[43f25b9ba173297b]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[944e8f57fc60541e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x7fca41b3238d - std::sys::pal::unix::thread::Thread::new::thread_start::h67ffc5859d05944d
  25:     0x7fca3b2969cb - <unknown>
  26:     0x7fca3b31aa4c - <unknown>
  27:                0x0 - <unknown>

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: rustc 1.91.0-nightly (8e3710ef3 2025-08-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z codegen-backend=cranelift -C link-dead-code=true -Z crate-attr=feature(async_drop) -Z crate-attr=feature(gen_blocks) -Z dump-mir-dir=dir

query stack during panic:
end of query stack
warning: 3 warnings emitted


@rustbot label +F-async_drop +F-gen_blocks

matthiaskrgr avatar Aug 23 '25 07:08 matthiaskrgr

Error: The feature relabel is not enabled in this repository. To enable it add its section in the triagebot.toml in the root of the repository.

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip.

rustbot avatar Aug 23 '25 07:08 rustbot

#![feature(async_drop)]
#![feature(gen_blocks)]

fn main() {
    let mut gn = gen {
        yield 1;
    };

    let _ = std::pin::pin!(unsafe { std::future::async_drop_in_place(&mut gn) })
        .poll(&mut std::task::Context::from_waker(std::task::Waker::noop()));
}

reproduces this without -Clink-dead-code=yes.

bjorn3 avatar Sep 26 '25 14:09 bjorn3