Skip to content

ice: miri: aggregate_field_path_elem: got non-aggregate type CoroutineClosure #120946

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

// edition:2021
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY

#![feature(async_closure, noop_waker, async_fn_traits)]

use std::future::Future;
use std::ops::{AsyncFnMut, AsyncFnOnce};
use std::pin::pin;
use std::task::*;

pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
    let mut fut = pin!(fut);
    let ctx = &mut Context::from_waker(Waker::noop());

    loop {
        match fut.as_mut().poll(ctx) {
            Poll::Pending => {}
            Poll::Ready(t) => break t,
        }
    }
}

async fn call_mut(f: &mut impl AsyncFnMut(i32)) {
    f(0).await;
}

async fn call_once(f: impl AsyncFnOnce(i32)) {
    f(1).await;
}

// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.mir
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.mir
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.coroutine_by_mut.0.mir
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.coroutine_by_move.0.mir
pub fn main() {
    block_on(async {
        let b = 2i32;
        let mut async_closure = async move |a: i32| {
            let a = &a;
            let b = &b;
        };
        call_mut(&mut async_closure).await;
        call_once(async_closure).await;
    });
}

Meta

rustc --version --verbose:

miri 0.1.0 (6cc4843 2024-02-10)

Error output

<output>
Backtrace

Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
WARNING: Ignoring `RUSTC_WRAPPER` environment variable, Miri does not support wrapping.
   Compiling mirice v0.1.0 (/tmp/im/mirice)
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner target/miri/x86_64-unknown-linux-gnu/debug/mirice`
warning: unused variable: `a`
  --> src/main.rs:40:17
   |
40 |             let a = &a;
   |                 ^ help: if this is intentional, prefix it with an underscore: `_a`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `b`
  --> src/main.rs:41:17
   |
41 |             let b = &b;
   |                 ^ help: if this is intentional, prefix it with an underscore: `_b`

error: internal compiler error: /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/compiler/rustc_const_eval/src/interpret/validity.rs:292:18: aggregate_field_path_elem: got non-aggregate type CoroutineClosure(DefId(0:17 ~ mirice[9343]::main::{closure#0}::{closure#0}), [i8, Binder(extern "RustCall" fn(std::future::ResumeTy, (i32,)) -> ((), ()), []), (i32,), Binder(fn() -> (&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) i32,), [Region(BrAnon)]), CoroutineWitness(DefId(0:18 ~ mirice[9343]::main::{closure#0}::{closure#0}::{closure#0}), [])])

thread 'rustc' panicked at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/compiler/rustc_errors/src/lib.rs:929:30:
Box<dyn Any>
stack backtrace:
   0:     0x7fb448a0b936 - std::backtrace_rs::backtrace::libunwind::trace::hce337a0fd0c5e1da
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fb448a0b936 - std::backtrace_rs::backtrace::trace_unsynchronized::hbc9b4a5cec9b81eb
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb448a0b936 - std::sys_common::backtrace::_print_fmt::habe453adcd959f3b
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fb448a0b936 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h67bb2d10ecb8af10
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fb448a5e380 - core::fmt::rt::Argument::fmt::hd5debad710e176b4
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/core/src/fmt/rt.rs:142:9
   5:     0x7fb448a5e380 - core::fmt::write::h5987d5bee25e3bd6
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fb4489ff0ef - std::io::Write::write_fmt::h0876e0f4bddb923c
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/io/mod.rs:1854:15
   7:     0x7fb448a0b714 - std::sys_common::backtrace::_print::h4ae69e83d64cbf46
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fb448a0b714 - std::sys_common::backtrace::print::h1d97d5831d0262fb
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fb448a0e4d7 - std::panicking::default_hook::{{closure}}::h39fabb1b3e65f47a
  10:     0x7fb448a0e239 - std::panicking::default_hook::h416520d6bb2cb53f
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/panicking.rs:292:9
  11:     0x7fb4457266dc - std[3acc11fb688f3d76]::panicking::update_hook::<alloc[408654ec2a1215fa]::boxed::Box<rustc_driver_impl[a7481a600b2f11a0]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fb448a0ec26 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2450ecbe2b1c1ea3
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/alloc/src/boxed.rs:2030:9
  13:     0x7fb448a0ec26 - std::panicking::rust_panic_with_hook::h99ef5cbc4b3b0ae4
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/panicking.rs:785:13
  14:     0x7fb445758034 - std[3acc11fb688f3d76]::panicking::begin_panic::<rustc_errors[1a010a4816a218fe]::ExplicitBug>::{closure#0}
  15:     0x7fb445754726 - std[3acc11fb688f3d76]::sys_common::backtrace::__rust_end_short_backtrace::<std[3acc11fb688f3d76]::panicking::begin_panic<rustc_errors[1a010a4816a218fe]::ExplicitBug>::{closure#0}, !>
  16:     0x7fb44574fe56 - std[3acc11fb688f3d76]::panicking::begin_panic::<rustc_errors[1a010a4816a218fe]::ExplicitBug>
  17:     0x7fb445763271 - <rustc_errors[1a010a4816a218fe]::diagnostic_builder::BugAbort as rustc_errors[1a010a4816a218fe]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7fb445b1a16e - <rustc_errors[1a010a4816a218fe]::DiagCtxt>::bug::<alloc[408654ec2a1215fa]::string::String>
  19:     0x7fb445bb505b - rustc_middle[9f94bb95ba4eb693]::util::bug::opt_span_bug_fmt::<rustc_span[4a89bdba9678f8e0]::span_encoding::Span>::{closure#0}
  20:     0x7fb445b9c2ea - rustc_middle[9f94bb95ba4eb693]::ty::context::tls::with_opt::<rustc_middle[9f94bb95ba4eb693]::util::bug::opt_span_bug_fmt<rustc_span[4a89bdba9678f8e0]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7fb445b9c188 - rustc_middle[9f94bb95ba4eb693]::ty::context::tls::with_context_opt::<rustc_middle[9f94bb95ba4eb693]::ty::context::tls::with_opt<rustc_middle[9f94bb95ba4eb693]::util::bug::opt_span_bug_fmt<rustc_span[4a89bdba9678f8e0]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7fb443b8f9e0 - rustc_middle[9f94bb95ba4eb693]::util::bug::bug_fmt
  23:     0x5557bd9cd04a - <rustc_const_eval[12fc7f34b1bb2601]::interpret::validity::ValidityVisitor<miri[827b2b8b4315e2f2]::machine::MiriMachine> as rustc_const_eval[12fc7f34b1bb2601]::interpret::visitor::ValueVisitor<miri[827b2b8b4315e2f2]::machine::MiriMachine>>::visit_field
  24:     0x5557bd9ce2c8 - <rustc_const_eval[12fc7f34b1bb2601]::interpret::validity::ValidityVisitor<miri[827b2b8b4315e2f2]::machine::MiriMachine> as rustc_const_eval[12fc7f34b1bb2601]::interpret::visitor::ValueVisitor<miri[827b2b8b4315e2f2]::machine::MiriMachine>>::visit_value
  25:     0x5557bd9a998a - <rustc_const_eval[12fc7f34b1bb2601]::interpret::eval_context::InterpCx<miri[827b2b8b4315e2f2]::machine::MiriMachine>>::validate_operand_internal
  26:     0x5557bd99ce8f - <rustc_const_eval[12fc7f34b1bb2601]::interpret::eval_context::InterpCx<miri[827b2b8b4315e2f2]::machine::MiriMachine>>::eval_rvalue_into_place
  27:     0x5557bda18ff3 - <rustc_const_eval[12fc7f34b1bb2601]::interpret::eval_context::InterpCx<miri[827b2b8b4315e2f2]::machine::MiriMachine> as miri[827b2b8b4315e2f2]::concurrency::thread::EvalContextExt>::run_threads
  28:     0x5557bda2a514 - miri[827b2b8b4315e2f2]::eval::eval_entry
  29:     0x5557bd86c693 - <miri[93aa4a3be542fe23]::MiriCompilerCalls as rustc_driver_impl[a7481a600b2f11a0]::Callbacks>::after_analysis
  30:     0x7fb44773a5ba - rustc_interface[57a4cb1189ffa880]::interface::run_compiler::<core[8df037f8ced6ea1f]::result::Result<(), rustc_span[4a89bdba9678f8e0]::ErrorGuaranteed>, rustc_driver_impl[a7481a600b2f11a0]::run_compiler::{closure#0}>::{closure#0}
  31:     0x7fb4477d2b46 - std[3acc11fb688f3d76]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[57a4cb1189ffa880]::util::run_in_thread_with_globals<rustc_interface[57a4cb1189ffa880]::util::run_in_thread_pool_with_globals<rustc_interface[57a4cb1189ffa880]::interface::run_compiler<core[8df037f8ced6ea1f]::result::Result<(), rustc_span[4a89bdba9678f8e0]::ErrorGuaranteed>, rustc_driver_impl[a7481a600b2f11a0]::run_compiler::{closure#0}>::{closure#0}, core[8df037f8ced6ea1f]::result::Result<(), rustc_span[4a89bdba9678f8e0]::ErrorGuaranteed>>::{closure#0}, core[8df037f8ced6ea1f]::result::Result<(), rustc_span[4a89bdba9678f8e0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8df037f8ced6ea1f]::result::Result<(), rustc_span[4a89bdba9678f8e0]::ErrorGuaranteed>>
  32:     0x7fb4477d2973 - <<std[3acc11fb688f3d76]::thread::Builder>::spawn_unchecked_<rustc_interface[57a4cb1189ffa880]::util::run_in_thread_with_globals<rustc_interface[57a4cb1189ffa880]::util::run_in_thread_pool_with_globals<rustc_interface[57a4cb1189ffa880]::interface::run_compiler<core[8df037f8ced6ea1f]::result::Result<(), rustc_span[4a89bdba9678f8e0]::ErrorGuaranteed>, rustc_driver_impl[a7481a600b2f11a0]::run_compiler::{closure#0}>::{closure#0}, core[8df037f8ced6ea1f]::result::Result<(), rustc_span[4a89bdba9678f8e0]::ErrorGuaranteed>>::{closure#0}, core[8df037f8ced6ea1f]::result::Result<(), rustc_span[4a89bdba9678f8e0]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8df037f8ced6ea1f]::result::Result<(), rustc_span[4a89bdba9678f8e0]::ErrorGuaranteed>>::{closure#1} as core[8df037f8ced6ea1f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7fb448a17eb5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h61e4d902e063b23d
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/alloc/src/boxed.rs:2016:9
  34:     0x7fb448a17eb5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfa3eaf4f75275f59
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/alloc/src/boxed.rs:2016:9
  35:     0x7fb448a17eb5 - std::sys::pal::unix::thread::Thread::new::thread_start::hb901d27f412b0ecd
                               at /rustc/6cc4843512d613f51ec81aba689180c31b0b28b6/library/std/src/sys/pal/unix/thread.rs:108:17
  36:     0x7fb4427bd9eb - <unknown>
  37:     0x7fb4428417cc - <unknown>
  38:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/miri/issues/new

note: please attach the file at `/tmp/im/mirice/rustc-ice-2024-02-11T21_09_07-2228199.txt` to your bug report

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

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

query stack during panic:
end of query stack

Miri caused an ICE during evaluation. Here's the interpreter backtrace at the time of the panic:
note: the place in the program where the ICE was triggered
  --> src/main.rs:44:19
   |
44 |         call_once(async_closure).await;
   |                   ^^^^^^^^^^^^^
   |
   = note: inside closure at src/main.rs:44:19: 44:32
note: inside `block_on::<(), {async block@src/main.rs:37:14: 45:6}>`
  --> src/main.rs:17:15
   |
17 |         match fut.as_mut().poll(ctx) {
   |               ^^^^^^^^^^^^^^^^^^^^^^
note: inside `main`
  --> src/main.rs:37:5
   |
37 | /     block_on(async {
38 | |         let b = 2i32;
39 | |         let mut async_closure = async move |a: i32| {
40 | |             let a = &a;
...  |
44 | |         call_once(async_closure).await;
45 | |     });
   | |______^
   = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71
   = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:155:18: 155:21
   = note: inside closure at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:166:18: 166:82
   = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:284:13: 284:31
   = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:554:40: 554:43
   = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:518:19: 518:81
   = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:142:14: 142:33
   = note: inside closure at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:148:48: 148:73
   = note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:554:40: 554:43
   = note: inside `std::panicking::r#try::<isize, {closure@std::rt::lang_start_internal::{closure#2}}>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:518:19: 518:81
   = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:142:14: 142:33
   = note: inside `std::rt::lang_start_internal` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:148:20: 148:98
   = note: inside `std::rt::lang_start::<()>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:165:17: 170:6

error: aborting due to 1 previous error; 2 warnings emitted

Metadata

Metadata

Labels

A-miriArea: The miri toolC-bugCategory: This is a bug.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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions