Skip to content

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

Open
@GunnarMorrigan

Description

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(<for<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'i, 'j, 'k, 'l, 'm, 'n, 'o, 'p, 'q, 'r, 's, 't, 'u, 'v> {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<Output = std::result::Result<i32, zbus::error::Error>>, impl futures::Future<Output = std::result::Result<i32, zbus::error::Error>>} 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 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9f8452425a9293aa
   1:     0x7ffde0d9f42b - core::fmt::write::h2eda102ff29c5ee0
   2:     0x7ffde0d5b899 - <std::io::IoSlice as core::fmt::Debug>::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 - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h50bc229817f9c976
   9:     0x7ffde0d66d99 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::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 - <rustc_trait_selection[cae6069403985fd3]::traits::fulfill::FulfillProcessor as rustc_data_structures[f61cfa0a0c0e7b14]::obligation_forest::ObligationProcessor>::process_obligation
  15:     0x7ffdcff43ab0 - <rustc_lint[ba9bc166ab672c34]::nonstandard_style::NonUpperCaseGlobals as rustc_lint[ba9bc166ab672c34]::passes::LateLintPass>::check_generic_param
  16:     0x7ffdd000abe1 - <rustc_trait_selection[cae6069403985fd3]::traits::fulfill::FulfillmentContext as rustc_infer[2c113e582cf24f1]::traits::engine::TraitEngine>::select_where_possible
  17:     0x7ffdcfb2c4ec - <polonius_engine[d666f5c24090ec1]::facts::AllFacts<rustc_borrowck[a4658bf187082e81]::facts::RustcFacts> 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 - <winapi_util[be25da47fda99d33]::file::Information>::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 - <rustc_middle[2d27bf43a2f0f270]::ty::instance::Instance>::expect_resolve
  29:     0x7ffdcf5aeb3d - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_constant
  30:     0x7ffdcf5ab99d - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  31:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  32:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  33:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  34:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  35:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  36:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  37:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  38:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  39:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  40:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  41:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  42:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  43:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  44:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  45:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  46:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  47:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  48:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  49:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  50:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  51:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  52:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  53:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  54:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  55:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  56:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  57:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  58:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  59:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  60:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  61:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  62:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  63:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  64:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  65:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  66:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  67:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  68:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  69:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::visit_operand
  70:     0x7ffdcf5acf3b - <rustc_monomorphize[86b5476df028a03b]::collector::MirUsedCollector as rustc_middle[2d27bf43a2f0f270]::mir::visit::Visitor>::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 - <rustc_query_impl[b3acef907b3c9332]::plumbing::QueryCtxt as rustc_query_system[f98e4918ea2c4399]::query::QueryContext>::depth_limit_error
  81:     0x7ffdcdb6d7d0 - <rustc_codegen_llvm[4a50c542f08b5a28]::llvm_::ffi::Type>::i8p_llcx
  82:     0x7ffdcdb528e9 - <rustc_codegen_llvm[4a50c542f08b5a28]::LlvmCodegenBackend as rustc_codegen_ssa[ad0b9fd6d43b463a]::traits::backend::CodegenBackend>::codegen_crate
  83:     0x7ffdcdb17db8 - rustc_interface[df1410a9ca1fcbf5]::passes::start_codegen
  84:     0x7ffdcdb25fb3 - rustc_interface[df1410a9ca1fcbf5]::util::build_output_filenames
  85:     0x7ffdcdb1da55 - <rustc_interface[df1410a9ca1fcbf5]::queries::Queries>::ongoing_codegen
  86:     0x7ffdcdad8f14 - rustc_driver_impl[47427ea40f3562ca]::main
  87:     0x7ffdcdaf8a3b - <rustc_middle[2d27bf43a2f0f270]::ty::SymbolName as core[cbb6584da310abea]::fmt::Debug>::fmt
  88:     0x7ffdcdaf6c76 - <rustc_middle[2d27bf43a2f0f270]::ty::SymbolName as core[cbb6584da310abea]::fmt::Debug>::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 `<axum_api::ApiState<hal::Cu, hal::ups_mon::UpsMon, hal::modem::ModemController, hal::led_ctrl::LedCtrl>::modem_info as axum::handler::Handler<(axum_core::extract::private::ViaParts, axum::extract::state::State<alloc::sync::Arc<axum_api::ApiState<hal::Cu, hal::ups_mon::UpsMon, hal::modem::ModemController, hal::led_ctrl::LedCtrl>>>), alloc::sync::Arc<axum_api::ApiState<hal::Cu, hal::ups_mon::UpsMon, hal::modem::ModemController, hal::led_ctrl::LedCtrl>>>>`
#2 [resolve_instance] resolving instance `<axum_api::ApiState<hal::Cu, hal::ups_mon::UpsMon, hal::modem::ModemController, hal::led_ctrl::LedCtrl>::modem_info as axum::handler::Handler<(axum_core::extract::private::ViaParts, axum::extract::state::State<alloc::sync::Arc<axum_api::ApiState<hal::Cu, hal::ups_mon::UpsMon, hal::modem::ModemController, hal::led_ctrl::LedCtrl>>>), alloc::sync::Arc<axum_api::ApiState<hal::Cu, hal::ups_mon::UpsMon, hal::modem::ModemController, hal::led_ctrl::LedCtrl>>>>::with_state`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-query-systemArea: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html)AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityS-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.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