Skip to content

ICE with incremental compilation in async code #93584

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
bnavetta opened this issue Feb 2, 2022 · 1 comment
Closed

ICE with incremental compilation in async code #93584

bnavetta opened this issue Feb 2, 2022 · 1 comment
Labels
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.

Comments

@bnavetta
Copy link

bnavetta commented Feb 2, 2022

I couldn't figure out how to minimize the code itself, but the exact same crate compiles successfully with incremental compilation disabled (by setting CARGO_INCREMENTAL=0) and fails with incremental compilation enabled. Running cargo clean also gets incremental compilation working again

Code

This looked like the function originally identified in the stack trace:

use camino::Utf8PathBuf;
use futures::prelude::*;
use miette::{IntoDiagnostic, WrapErr};
use tokio::sync::mpsc;
use tracing::{debug, trace, error, info, instrument};

use evdev_async::{AsyncDevice, InputEvent, KeyEvent};

use crate::{supervisor::Shutdown, dispatcher::Event};

#[instrument(skip(stop))]
pub async fn watch(path: Utf8PathBuf, dispatch_tx: mpsc::Sender<Event>, mut stop: Shutdown) -> miette::Result<()> {
    let mut device = AsyncDevice::new(&path)
        .into_diagnostic()
        .wrap_err_with(|| format!("could not open evdev device {}", path))?;

    info!(%path, "Watching input device");

    loop {
        tokio::select! {
            _ = stop.shutdown() => {
                debug!("Shutting down watcher loop");
                break;
            },
            event = device.next() => {
                match event {
                    Some(Ok(ev)) => {
                        let event = InputEvent::from(ev);
                        trace!(?event, "Received input event");

                        if let InputEvent::Key(ev) = event {
                            let dispatch_event = match ev {
                                KeyEvent::Press(code) => Event::KeyPress(code),
                                KeyEvent::Release(code) => Event::KeyRelease(code),
                            };

                            dispatch_tx.send(dispatch_event).await
                                .into_diagnostic()
                                .wrap_err("dispatcher closed")?;
                        }
                    },
                    Some(Err(err)) => {
                        error!(?err, "Failure reading input events");
                    },
                    None => {
                        info!("Input device has closed");
                        break;
                    },
                }

            }
        }
    }

    Ok(())
}

Meta

rustc --version --verbose:

rustc 1.59.0-nightly (83b15bfe1 2021-12-28)
binary: rustc
commit-hash: 83b15bfe1c15f325bc186ebfe3691b729ed59f2b
commit-date: 2021-12-28
host: x86_64-unknown-linux-gnu
release: 1.59.0-nightly
LLVM version: 13.0.0

Error output

Compiling hotkey-daemon v0.1.0 (/home/ben/src/evhotkeyd/hotkey-daemon)                                                                                                                                           
warning: associated function is never used: `is_shutdown`                                                                                                                                                           
   --> hotkey-daemon/src/supervisor.rs:197:12                                                                                                                                                                       
    |                                                                                                                                                                                                               
197 |     pub fn is_shutdown(&self) -> bool {                                                                                                                                                                       
    |            ^^^^^^^^^^^                                                                                                                                                                                        
    |                                                                                                                                                                                                               
    = note: `#[warn(dead_code)]` on by default                                                                                                                                                                      
                                                                                                                                                                                                                    
warning: `hotkey-daemon` (lib) generated 1 warning                                                                                                                                                                  
thread 'rustc' panicked at 'no entry found for key', compiler/rustc_metadata/src/rmeta/decoder.rs:1627:13                                                                                                           
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace                                                                                                                                       
                                                                                                                                                                                                                    
error: internal compiler error: unexpected panic                                                                                                                                                                    
                                                                                                                                                                                                                    
note: 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.59.0-nightly (83b15bfe1 2021-12-28) running on x86_64-unknown-linux-gnu                                                                                                                               
                                                                                                                                                                                                                    
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin                                                                                                                            
                                                                                                                                                                                                                    
note: some of the compiler flags provided by cargo are hidden                                                                                                                                                       
                                                                                                                                                                                                                    
query stack during panic:                                                                                                                                                                                           
#0 [codegen_fulfill_obligation] checking if `core::future::into_future::IntoFuture` fulfills its obligations                                                                                                        
#1 [resolve_instance] resolving instance `<tokio::future::poll_fn::PollFn<[closure@hotkey_daemon::device_watcher::watch::{closure#0}::{closure#0}::{closure#1}]> as core::future::into_future::IntoFuture>::into_future`                                                                                                                                                                                                                
end of query stack                                                                                                                                                                                                  
error: could not compile `hotkey-daemon`
Backtrace

thread 'rustc' panicked at 'no entry found for key', compiler/rustc_metadata/src/rmeta/decoder.rs:1627:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/83b15bfe1c15f325bc186ebfe3691b729ed59f2b/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/83b15bfe1c15f325bc186ebfe3691b729ed59f2b/library/core/src/panicking.rs:107:14
   2: core::panicking::panic_display
             at /rustc/83b15bfe1c15f325bc186ebfe3691b729ed59f2b/library/core/src/panicking.rs:63:5
   3: core::panicking::panic_str
             at /rustc/83b15bfe1c15f325bc186ebfe3691b729ed59f2b/library/core/src/panicking.rs:55:5
   4: core::option::expect_failed
             at /rustc/83b15bfe1c15f325bc186ebfe3691b729ed59f2b/library/core/src/option.rs:1821:5
   5: <rustc_metadata::creader::CStore as rustc_session::cstore::CrateStore>::expn_hash_to_expn_id
   6: <rustc_span::hygiene::ExpnId as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   7: <rustc_span::hygiene::SyntaxContextData as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   8: <rustc_query_impl::on_disk_cache::CacheDecoder as rustc_middle::ty::codec::TyDecoder>::with_position::<<rustc_span::hygiene::SyntaxContext as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}::{closure#0}, core::result::Result<rustc_span::hygiene::SyntaxContextData, alloc::string::String>>
   9: <rustc_span::span_encoding::Span as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  10: <rustc_middle::ty::VariantDef as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  11: <rustc_query_impl::on_disk_cache::CacheDecoder as rustc_serialize::serialize::Decoder>::read_seq::<alloc::vec::Vec<rustc_middle::ty::VariantDef>, <alloc::vec::Vec<rustc_middle::ty::VariantDef> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>
  12: <rustc_middle::ty::adt::AdtDef as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  13: <rustc_middle::ty::sty::TyKind as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  14: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  15: <core::result::Result<rustc_middle::ty::subst::GenericArg, alloc::string::String> as rustc_middle::ty::context::InternIteratorElement<rustc_middle::ty::subst::GenericArg, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>>>::intern_with::<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>, <rustc_middle::ty::context::TyCtxt>::mk_substs<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>::{closure#0}>
  16: <rustc_middle::ty::sty::TyKind as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  17: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  18: <core::result::Result<&rustc_middle::ty::TyS, alloc::string::String> as rustc_middle::ty::context::InternIteratorElement<&rustc_middle::ty::TyS, &rustc_middle::ty::list::List<&rustc_middle::ty::TyS>>>::intern_with::<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <rustc_middle::ty::list::List<&rustc_middle::ty::TyS> as rustc_middle::ty::codec::RefDecodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>, <rustc_middle::ty::context::TyCtxt>::mk_type_list<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <rustc_middle::ty::list::List<&rustc_middle::ty::TyS> as rustc_middle::ty::codec::RefDecodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>::{closure#0}>
  19: <rustc_middle::ty::list::List<&rustc_middle::ty::TyS> as rustc_middle::ty::codec::RefDecodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  20: <rustc_middle::ty::sty::Binder<rustc_middle::ty::sty::FnSig> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  21: <rustc_middle::ty::sty::TyKind as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  22: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  23: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  24: <smallvec::SmallVec<[rustc_middle::ty::subst::GenericArg; 8]> as core::iter::traits::collect::Extend<rustc_middle::ty::subst::GenericArg>>::extend::<core::iter::adapters::ResultShunt<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>, alloc::string::String>>
  25: <core::result::Result<rustc_middle::ty::subst::GenericArg, alloc::string::String> as rustc_middle::ty::context::InternIteratorElement<rustc_middle::ty::subst::GenericArg, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>>>::intern_with::<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>, <rustc_middle::ty::context::TyCtxt>::mk_substs<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>::{closure#0}>
  26: <rustc_middle::ty::sty::TyKind as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  27: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  28: <core::result::Result<rustc_middle::ty::subst::GenericArg, alloc::string::String> as rustc_middle::ty::context::InternIteratorElement<rustc_middle::ty::subst::GenericArg, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>>>::intern_with::<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>, <rustc_middle::ty::context::TyCtxt>::mk_substs<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>::{closure#0}>
  29: <rustc_middle::ty::sty::TyKind as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  30: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  31: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  32: <rustc_middle::ty::context::TyCtxt>::mk_substs::<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>
  33: <rustc_middle::traits::ImplSource<()> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  34: <core::result::Result<rustc_middle::traits::ImplSource<()>, rustc_errors::ErrorReported> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  35: <rustc_query_impl::on_disk_cache::OnDiskCache>::try_load_query_result::<core::result::Result<rustc_middle::traits::ImplSource<()>, rustc_errors::ErrorReported>>
  36: <<rustc_query_impl::queries::codegen_fulfill_obligation as rustc_query_system::query::config::QueryDescription<rustc_query_impl::plumbing::QueryCtxt>>::TRY_LOAD_FROM_DISK::{closure#0} as core::ops::function::FnOnce<(rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::dep_graph::serialized::SerializedDepNodeIndex)>>::call_once
  37: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, (rustc_middle::ty::ParamEnv, rustc_middle::ty::sty::Binder<rustc_middle::ty::sty::TraitRef>), core::result::Result<rustc_middle::traits::ImplSource<()>, rustc_errors::ErrorReported>>
  38: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(rustc_middle::ty::ParamEnv, rustc_middle::ty::sty::Binder<rustc_middle::ty::sty::TraitRef>), core::result::Result<rustc_middle::traits::ImplSource<()>, rustc_errors::ErrorReported>>>
  39: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::codegen_fulfill_obligation
  40: rustc_ty_utils::instance::inner_resolve_instance
  41: rustc_ty_utils::instance::resolve_instance
  42: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, rustc_middle::ty::ParamEnvAnd<(rustc_span::def_id::DefId, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>)>, core::result::Result<core::option::Option<rustc_middle::ty::instance::Instance>, rustc_errors::ErrorReported>>
  43: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::resolve_instance, rustc_query_impl::plumbing::QueryCtxt>
  44: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::resolve_instance
  45: <rustc_middle::ty::instance::Instance>::resolve
  46: rustc_monomorphize::collector::collect_neighbours
  47: rustc_monomorphize::collector::collect_items_rec
  48: rustc_monomorphize::collector::collect_items_rec
  49: rustc_monomorphize::collector::collect_items_rec
  50: rustc_monomorphize::collector::collect_items_rec
  51: rustc_monomorphize::collector::collect_items_rec
  52: rustc_monomorphize::collector::collect_items_rec
  53: rustc_monomorphize::collector::collect_items_rec
  54: rustc_monomorphize::collector::collect_items_rec
  55: rustc_monomorphize::collector::collect_items_rec
  56: rustc_monomorphize::collector::collect_items_rec
  57: rustc_monomorphize::collector::collect_items_rec
  58: rustc_monomorphize::collector::collect_items_rec
  59: rustc_monomorphize::collector::collect_items_rec
  60: rustc_monomorphize::collector::collect_items_rec
  61: rustc_monomorphize::collector::collect_items_rec
  62: rustc_monomorphize::collector::collect_items_rec
  63: rustc_monomorphize::collector::collect_items_rec
  64: rustc_monomorphize::collector::collect_items_rec
  65: rustc_monomorphize::collector::collect_items_rec
  66: rustc_monomorphize::collector::collect_items_rec
  67: rustc_monomorphize::collector::collect_items_rec
  68: rustc_monomorphize::collector::collect_items_rec
  69: rustc_monomorphize::collector::collect_items_rec
  70: rustc_monomorphize::collector::collect_items_rec
  71: rustc_monomorphize::collector::collect_items_rec
  72: rustc_monomorphize::collector::collect_items_rec
  73: rustc_monomorphize::collector::collect_items_rec
  74: rustc_monomorphize::collector::collect_items_rec
  75: rustc_monomorphize::collector::collect_items_rec
  76: rustc_monomorphize::collector::collect_items_rec
  77: rustc_monomorphize::collector::collect_items_rec
  78: rustc_monomorphize::collector::collect_items_rec
  79: rustc_monomorphize::collector::collect_items_rec
  80: rustc_monomorphize::collector::collect_items_rec
  81: rustc_monomorphize::collector::collect_items_rec
  82: rustc_monomorphize::collector::collect_items_rec
  83: rustc_monomorphize::collector::collect_items_rec
  84: rustc_monomorphize::collector::collect_items_rec
  85: rustc_monomorphize::collector::collect_items_rec
  86: rustc_monomorphize::collector::collect_items_rec
  87: rustc_monomorphize::collector::collect_items_rec
  88: rustc_monomorphize::collector::collect_items_rec
  89: rustc_monomorphize::collector::collect_items_rec

@bnavetta bnavetta 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 Feb 2, 2022
@Aaron1011
Copy link
Member

This is fixed in the latest nightly by #92533

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

2 participants