rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.74k stars 12.5k forks source link

ICE: "forcing query with already existing `DepNode`" with many async calls #112456

Open GunnarMorrigan opened 1 year ago

GunnarMorrigan commented 1 year ago

Code

I can not provide all rust code and I was unable to recreate a minimal reproducable example. I have tried for some time now. I currently run nightly to have access to async in trait feature. The async in trait is used to abstract dbus implementations using zbus for production and for development a direct object is returned. The zbus production code performs 1 proxy creation async call and 16 dbus calls.

If I remove all the async dbus calls rustc does not crash:

pub trait ModemTrait: Sized + Send + Sync + 'static {
    fn new() -> impl Future<Output = Result<Self, HalError>> + Send;
    fn get_modem_info(&self) -> impl Future<Output = Result<ModemInfo, HalError>> + Send + '_;
}

pub struct ModemController {
    conn: Connection,
}

impl ModemTrait for ModemController {
    async fn new() -> Result<Self, HalError> {
        let conn = Connection::system().await?;

        let ret = Self { conn };

        Ok(ret)
    }

    fn get_modem_info(&self) -> impl Future<Output = Result<ModemInfo, HalError>> + Send + '_ {
        async {
            let proxy = PppDbusProxy::new(&self.conn).await?;

            // Ok(ModemInfo::default())

            Ok(ModemInfo {
                sim_pin_status: proxy.get_sim_pin_status().await?,
                initialized: proxy.is_initialized().await?,
                online: proxy.is_online().await?,
                modem_manufacturer: proxy.get_modem_manufacturer().await?,
                modem_model: proxy.get_modem_model().await?,
                modem_imei: proxy.get_modem_imei().await?,
                modem_firmware_version: proxy.get_modem_firmware_version().await?,
                iccid: proxy.get_ccid().await?,
                network_type: proxy.get_network_type().await?,
                network_operator: proxy.get_network_operator().await?,
                signal_power: proxy.get_signal_power().await?,
                signal_power_condition: proxy.get_signal_power_condition().await?,
                signal_quality_rating: proxy.get_signal_quality_rating().await?,
                signal_quality_source: proxy.get_signal_quality_source().await?,
                mobile_network_operator_profile: proxy
                    .get_mobile_network_operators_profile()
                    .await?,
                ppp_connection_start: proxy.get_ppp_connection_start_time().await?,
            })
        }
    }
}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (a97c36dd2 2023-06-07)
binary: rustc
commit-hash: a97c36dd2e6f711949fc9b790476e93bd9e6d1f4
commit-date: 2023-06-07
host: x86_64-pc-windows-msvc
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

See backtrace

Backtrace

``` thread 'rustc' panicked at 'forcing query with already existing `DepNode` - query-key: Canonical { value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, constness: NotConst }, value: Binder(TraitPredicate( {std::future::ResumeTy, &'a hal::modem::PppDbusProxy<'b>, hal::modem::PppDbusProxy<'c>, &'d zbus::proxy::Proxy<'e>, zbus::proxy::Proxy<'f>, &'g str, (), &'h (), impl futures::Future>, impl futures::Future>} as std::marker::Send>, polarity:Positive), []) }, max_universe: U0, variables: [] } - dep-node: evaluate_obligation(b9c844e08ed73076-be2511b0687549ec)', /rustc/a97c36dd2e6f711949fc9b790476e93bd9e6d1f4\compiler\rustc_query_system\src\dep_graph\graph.rs:350:9 stack backtrace: 0: 0x7ffde0d6616c - ::fmt::h9f8452425a9293aa 1: 0x7ffde0d9f42b - core::fmt::write::h2eda102ff29c5ee0 2: 0x7ffde0d5b899 - ::fmt::he00f0eb5510d32b6 3: 0x7ffde0d65f1b - std::sys::common::alloc::realloc_fallback::h0fb58e6852cd6235 4: 0x7ffde0d69779 - std::panicking::default_hook::h3f902ef65094b7fd 5: 0x7ffde0d6942f - std::panicking::default_hook::h3f902ef65094b7fd 6: 0x7ffdd02758ba - rustc_driver_impl[47427ea40f3562ca]::install_ice_hook 7: 0x7ffde0d69ea0 - std::panicking::rust_panic_with_hook::h8862750156c5b4fc 8: 0x7ffde0d69c2d - ::get::h50bc229817f9c976 9: 0x7ffde0d66d99 - ::fmt::h9f8452425a9293aa 10: 0x7ffde0d69930 - rust_begin_unwind 11: 0x7ffde0dd2e25 - core::panicking::panic_fmt::h183ebee5e4d5a07e 12: 0x7ffdcfc208a4 - rustc_query_impl[b3acef907b3c9332]::query_callbacks 13: 0x7ffdcfbf8aa7 - rustc_query_impl[b3acef907b3c9332]::query_callbacks 14: 0x7ffdd000d59a - ::process_obligation 15: 0x7ffdcff43ab0 - ::check_generic_param 16: 0x7ffdd000abe1 - ::select_where_possible 17: 0x7ffdcfb2c4ec - as rustc_borrowck[a4658bf187082e81]::facts::AllFactsExt>::enabled 18: 0x7ffdcfb8dce4 - rustc_query_impl[b3acef907b3c9332]::query_callbacks 19: 0x7ffdcfbb89e4 - rustc_query_impl[b3acef907b3c9332]::query_callbacks 20: 0x7ffdce5e8bf5 - rustc_query_impl[b3acef907b3c9332]::profiling_support::alloc_self_profile_query_strings 21: 0x7ffdce53a7aa - rustc_query_impl[b3acef907b3c9332]::profiling_support::alloc_self_profile_query_strings 22: 0x7ffdcfc53d18 - rustc_query_impl[b3acef907b3c9332]::query_callbacks 23: 0x7ffdcfbcd3dc - rustc_query_impl[b3acef907b3c9332]::query_callbacks 24: 0x7ffdcf38e201 - ::number_of_links 25: 0x7ffdcfb8d550 - rustc_query_impl[b3acef907b3c9332]::query_callbacks 26: 0x7ffdcfc19434 - rustc_query_impl[b3acef907b3c9332]::query_callbacks 27: 0x7ffdcfbf8e49 - rustc_query_impl[b3acef907b3c9332]::query_callbacks 28: 0x7ffdd01044df - ::expect_resolve 29: 0x7ffdcf5aeb3d - ::visit_constant 30: 0x7ffdcf5ab99d - ::visit_operand 31: 0x7ffdcf5acf3b - ::visit_operand 32: 0x7ffdcf5acf3b - ::visit_operand 33: 0x7ffdcf5acf3b - ::visit_operand 34: 0x7ffdcf5acf3b - ::visit_operand 35: 0x7ffdcf5acf3b - ::visit_operand 36: 0x7ffdcf5acf3b - ::visit_operand 37: 0x7ffdcf5acf3b - ::visit_operand 38: 0x7ffdcf5acf3b - ::visit_operand 39: 0x7ffdcf5acf3b - ::visit_operand 40: 0x7ffdcf5acf3b - ::visit_operand 41: 0x7ffdcf5acf3b - ::visit_operand 42: 0x7ffdcf5acf3b - ::visit_operand 43: 0x7ffdcf5acf3b - ::visit_operand 44: 0x7ffdcf5acf3b - ::visit_operand 45: 0x7ffdcf5acf3b - ::visit_operand 46: 0x7ffdcf5acf3b - ::visit_operand 47: 0x7ffdcf5acf3b - ::visit_operand 48: 0x7ffdcf5acf3b - ::visit_operand 49: 0x7ffdcf5acf3b - ::visit_operand 50: 0x7ffdcf5acf3b - ::visit_operand 51: 0x7ffdcf5acf3b - ::visit_operand 52: 0x7ffdcf5acf3b - ::visit_operand 53: 0x7ffdcf5acf3b - ::visit_operand 54: 0x7ffdcf5acf3b - ::visit_operand 55: 0x7ffdcf5acf3b - ::visit_operand 56: 0x7ffdcf5acf3b - ::visit_operand 57: 0x7ffdcf5acf3b - ::visit_operand 58: 0x7ffdcf5acf3b - ::visit_operand 59: 0x7ffdcf5acf3b - ::visit_operand 60: 0x7ffdcf5acf3b - ::visit_operand 61: 0x7ffdcf5acf3b - ::visit_operand 62: 0x7ffdcf5acf3b - ::visit_operand 63: 0x7ffdcf5acf3b - ::visit_operand 64: 0x7ffdcf5acf3b - ::visit_operand 65: 0x7ffdcf5acf3b - ::visit_operand 66: 0x7ffdcf5acf3b - ::visit_operand 67: 0x7ffdcf5acf3b - ::visit_operand 68: 0x7ffdcf5acf3b - ::visit_operand 69: 0x7ffdcf5acf3b - ::visit_operand 70: 0x7ffdcf5acf3b - ::visit_operand 71: 0x7ffdce2c469a - rustc_monomorphize[86b5476df028a03b]::provide 72: 0x7ffdce2c42f2 - rustc_monomorphize[86b5476df028a03b]::provide 73: 0x7ffdce2c0009 - rustc_monomorphize[86b5476df028a03b]::provide 74: 0x7ffdce2c0a50 - rustc_monomorphize[86b5476df028a03b]::provide 75: 0x7ffdce52b92a - rustc_query_impl[b3acef907b3c9332]::profiling_support::alloc_self_profile_query_strings 76: 0x7ffdce50eaad - rustc_query_impl[b3acef907b3c9332]::profiling_support::alloc_self_profile_query_strings 77: 0x7ffdce5e8a8c - rustc_query_impl[b3acef907b3c9332]::profiling_support::alloc_self_profile_query_strings 78: 0x7ffdce538be7 - rustc_query_impl[b3acef907b3c9332]::profiling_support::alloc_self_profile_query_strings 79: 0x7ffdce59bc4a - rustc_query_impl[b3acef907b3c9332]::profiling_support::alloc_self_profile_query_strings 80: 0x7ffdd2093d00 - ::depth_limit_error 81: 0x7ffdcdb6d7d0 - ::i8p_llcx 82: 0x7ffdcdb528e9 - ::codegen_crate 83: 0x7ffdcdb17db8 - rustc_interface[df1410a9ca1fcbf5]::passes::start_codegen 84: 0x7ffdcdb25fb3 - rustc_interface[df1410a9ca1fcbf5]::util::build_output_filenames 85: 0x7ffdcdb1da55 - ::ongoing_codegen 86: 0x7ffdcdad8f14 - rustc_driver_impl[47427ea40f3562ca]::main 87: 0x7ffdcdaf8a3b - ::fmt 88: 0x7ffdcdaf6c76 - ::fmt 89: 0x7ffde0d7d2cc - std::sys::windows::thread::Thread::new::hdc4d105fd5a00159 90: 0x7ffe83ef7614 - BaseThreadInitThunk 91: 0x7ffe842426a1 - RtlUserThreadStart 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: rustc 1.72.0-nightly (a97c36dd2 2023-06-07) running on x86_64-pc-windows-msvc 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 [evaluate_obligation] evaluating trait selection obligation `for<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v> {core::future::ResumeTy, &'a hal::modem::PppDbusProxy<'b>, hal::modem::PppDbusProxy<'c>, &'d zbus::proxy::Proxy<'e>, zbus::proxy::Proxy<'f>, &'g str, (), &'h (), zbus::proxy::Proxy<'a>::call::{opaque#0}, zbus::proxy::Proxy<'a>::call::{opaque#0}}: core::marker::Send` #1 [codegen_select_candidate] computing candidate for `::modem_info as axum::handler::Handler<(axum_core::extract::private::ViaParts, axum::extract::state::State>>), alloc::sync::Arc>>>` #2 [resolve_instance] resolving instance `::modem_info as axum::handler::Handler<(axum_core::extract::private::ViaParts, axum::extract::state::State>>), alloc::sync::Arc>>>::with_state` #3 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack ```

kpreid commented 8 months ago

Relabeling issues which don't have a runnable reproduction (as opposed to not having a minimized one) to the new label S-needs-repro. @rustbot label +S-needs-repro -E-needs-mcve