Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Panic when checking Send obligation of type alias #92552

Closed
ChosunOne opened this issue Jan 4, 2022 · 7 comments
Closed

Panic when checking Send obligation of type alias #92552

ChosunOne opened this issue Jan 4, 2022 · 7 comments
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

@ChosunOne
Copy link

Code

I'm not really sure what causes the crash, I'm using a lot of generic types here, and the snippets are just a fraction of the codebase.

/// Marker type for a `Client<G, Teacher>`, indicates the client has teacher privileges
#[derive(Debug)]
pub struct Teacher;
/// Marker type for a `Client<G, Student>`, indicates the client has student privileges
#[derive(Debug)]
pub struct Student;

where G is of the form:

pub trait GenericTypes {
    type A: Send + Sync;
    type B: Send + Sync;
    type C: Send + Sync;
    ...
}

Later on, in my tests module

pub type TestClient = Client<MockTransport, Student>;

Meta

rustc --version --verbose:

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0

It should be noted that I don't see this error in the latest beta or nightly versions, but I'm not sure if this crash was known so I'm reporting it here anyway.

Error output

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.57.0 (f1edd0429 2021-11-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `client::client::Client<track::track::tests::MockTransport, client::Student>: core::marker::Send`
#1 [codegen_fulfill_obligation] checking if `core::ops::unsize::CoerceUnsized` fulfills its obligations
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
Backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/compiler/rustc_hir/src/definitions.rs:452:14
stack backtrace:
   0:     0x7fcebd773a9c - std::backtrace_rs::backtrace::libunwind::trace::hf6a6dfd7da937cb0
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fcebd773a9c - std::backtrace_rs::backtrace::trace_unsynchronized::hc596a19e4891f7f3
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fcebd773a9c - std::sys_common::backtrace::_print_fmt::hb16700db31584325
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fcebd773a9c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h231c4190cfa75162
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fcebd7d0fdc - core::fmt::write::h2a1462b5f8eea807
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/fmt/mod.rs:1163:17
   5:     0x7fcebd763c05 - std::io::Write::write_fmt::h71ddfebc68685972
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/io/mod.rs:1696:15
   6:     0x7fcebd776f60 - std::sys_common::backtrace::_print::hcc197d4bebf2b369
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fcebd776f60 - std::sys_common::backtrace::print::h335a66af06738c7c
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fcebd776f60 - std::panicking::default_hook::{{closure}}::h6fac9ac9c8b79e52
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:210:50
   9:     0x7fcebd776b15 - std::panicking::default_hook::h341c1030c6a1161b
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:227:9
  10:     0x7fcebdf632b1 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h932547f60770f26a
  11:     0x7fceae2b3913 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h6021c1ed92b6e8cb
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1705:9
  12:     0x7fceae2cb06d - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h86a896c12f622ba8
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/proc_macro/src/bridge/client.rs:320:21
  13:     0x7fcebd777779 - std::panicking::rust_panic_with_hook::h50680ff4b44510c6
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:628:17
  14:     0x7fcebd777202 - std::panicking::begin_panic_handler::{{closure}}::h9371c0fbb1e8465a
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:519:13
  15:     0x7fcebd773f44 - std::sys_common::backtrace::__rust_end_short_backtrace::h9b3efa22a5768c0f
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:139:18
  16:     0x7fcebd777199 - rust_begin_unwind
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
  17:     0x7fcebd73b441 - core::panicking::panic_fmt::h23b9203e89cc61cf
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
  18:     0x7fcebd73b38d - core::panicking::panic::h0ba7146865b2f9d6
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:50:5
  19:     0x7fcebf766b47 - <rustc_query_impl::on_disk_cache::OnDiskCache as rustc_middle::ty::context::OnDiskCache>::def_path_hash_to_def_id::hb925ab58899dddff
  20:     0x7fcebfad2b21 - rustc_middle::dep_graph::dep_node::<impl rustc_query_system::dep_graph::dep_node::DepNodeParams<rustc_middle::ty::context::TyCtxt> for rustc_span::def_id::LocalDefId>::recover::h2e76aa40aab4da19
  21:     0x7fcec015d52c - rustc_query_impl::query_callbacks::hir_owner::force_from_dep_node::hc7fd02f51ac51090
  22:     0x7fcebf751d6a - rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green::h14b50df9818693f3
  23:     0x7fcebf751d41 - rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green::h14b50df9818693f3
  24:     0x7fcebf751d41 - rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green::h14b50df9818693f3
  25:     0x7fcebf751d41 - rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green::h14b50df9818693f3
  26:     0x7fcebf751d41 - rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green::h14b50df9818693f3
  27:     0x7fcebf751d41 - rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green::h14b50df9818693f3
  28:     0x7fcebf751d41 - rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green::h14b50df9818693f3
  29:     0x7fcebf751d41 - rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green::h14b50df9818693f3
  30:     0x7fcebf751d41 - rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green::h14b50df9818693f3
  31:     0x7fcebf6deecc - rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::h0eb1b79b9e091780
  32:     0x7fcebf6fb66d - rustc_query_system::query::plumbing::get_query::he848c9a74d759f95
  33:     0x7fcebf74dd24 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::evaluate_obligation::h2b78688237f47182
  34:     0x7fcebf9669d9 - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation::h8dd6b3a9b1045c30
  35:     0x7fcebf966e00 - <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow::h9254e4a68f95d40c
  36:     0x7fcebf98961d - rustc_trait_selection::traits::fulfill::FulfillProcessor::process_trait_obligation::hd2a96a9f24be244a
  37:     0x7fcebf982c03 - rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations::hfe1bcc41b6d0982a
  38:     0x7fcebf9b599d - rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations::h44a6a3ba4a0d74cb
  39:     0x7fcebf982059 - rustc_trait_selection::traits::fulfill::FulfillmentContext::select::hbd72a111ba645b38
  40:     0x7fcebf982426 - <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_all_or_error::h942ace5c00efd47d
  41:     0x7fcebf9c1750 - rustc_trait_selection::traits::codegen::drain_fulfillment_cx_or_panic::h4908742f391981cc
  42:     0x7fcebf95c245 - rustc_infer::infer::InferCtxtBuilder::enter::habb43cdb81f2c72a
  43:     0x7fcebf9c169e - rustc_trait_selection::traits::codegen::codegen_fulfill_obligation::h4433958878c36d51
  44:     0x7fcec019b897 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h7a07243826cf1d24
  45:     0x7fcec013250d - rustc_data_structures::stack::ensure_sufficient_stack::h62b651a5fb402b42
  46:     0x7fcebf6f3e57 - rustc_query_system::query::plumbing::get_query::h9775ae7e1c0b1b0a
  47:     0x7fcebf74c95c - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::codegen_fulfill_obligation::h584ad960973efb02
  48:     0x7fcebfd1cca0 - rustc_monomorphize::custom_coerce_unsize_info::hc2c29fcbcca6e847
  49:     0x7fcebfd1a39d - rustc_monomorphize::collector::find_vtable_types_for_unsizing::hffd8d54c06969b72
  50:     0x7fcebf22612a - <rustc_monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_rvalue::he96157441d8e117d
  51:     0x7fcebf22abb8 - rustc_monomorphize::collector::collect_neighbours::heee4045137be387f
  52:     0x7fcebf224732 - rustc_monomorphize::collector::collect_items_rec::haa77a1b02aa9f066
  53:     0x7fcebf224887 - rustc_monomorphize::collector::collect_items_rec::haa77a1b02aa9f066
  54:     0x7fcebf224887 - rustc_monomorphize::collector::collect_items_rec::haa77a1b02aa9f066
  55:     0x7fcebf224887 - rustc_monomorphize::collector::collect_items_rec::haa77a1b02aa9f066
  56:     0x7fcebf224887 - rustc_monomorphize::collector::collect_items_rec::haa77a1b02aa9f066
  57:     0x7fcebf224887 - rustc_monomorphize::collector::collect_items_rec::haa77a1b02aa9f066
  58:     0x7fcebfd16fc1 - rustc_session::utils::<impl rustc_session::session::Session>::time::h7ad27f3fef63d60c
  59:     0x7fcebfd1a043 - rustc_monomorphize::collector::collect_crate_mono_items::hcae2aed89781160b
  60:     0x7fcebf2220e3 - rustc_monomorphize::partitioning::collect_and_partition_mono_items::he4bd85bd889ca8ac
  61:     0x7fcebe8ddc8a - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hd3653e4874855fd3
  62:     0x7fcebe92edb4 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h3747b31f10ef26fd
  63:     0x7fcebe8bbf7e - rustc_data_structures::stack::ensure_sufficient_stack::hba79ecc262cb9237
  64:     0x7fcec005778d - rustc_query_system::query::plumbing::try_execute_query::h23120d2eae92ab93
  65:     0x7fcec016f0a4 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_and_partition_mono_items::hefaa9a7b196acf15
  66:     0x7fcebfbd63a5 - rustc_codegen_ssa::base::codegen_crate::h7a10ba1a5bbbde6f
  67:     0x7fcebfc02e7a - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::ha56c5fc04fb5674a
  68:     0x7fcebfb73f7d - rustc_interface::queries::Queries::ongoing_codegen::h11dabf965b22130b
  69:     0x7fcebfb489aa - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hf84cd18c24bd5171
  70:     0x7fcebfb360ee - rustc_span::with_source_map::h6ab8a240e103b5b9
  71:     0x7fcebfb482ac - scoped_tls::ScopedKey<T>::set::hd1fbd64c6f645895
  72:     0x7fcebfb36ef5 - std::sys_common::backtrace::__rust_begin_short_backtrace::h0a1328c9fa7f7448
  73:     0x7fcebfb62962 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ea1ced06d6b3e97
  74:     0x7fcebd782933 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7bd677a5dc988be6
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1691:9
  75:     0x7fcebd782933 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7b1c1ba11c4db785
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1691:9
  76:     0x7fcebd782933 - std::sys::unix::thread::Thread::new::thread_start::h9c58c0d12d84e854
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys/unix/thread.rs:106:17
  77:     0x7fcebd69e609 - start_thread
                               at /build/glibc-eX1tMB/glibc-2.31/nptl/pthread_create.c:477:8
  78:     0x7fcebd5b2293 - clone
  79:                0x0 - <unknown>

@ChosunOne ChosunOne 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 Jan 4, 2022
@ChosunOne
Copy link
Author

If I simply remove the type alias, things seem to work just fine when it uses inference for the type instead in my tests.

@compiler-errors
Copy link
Member

Does this continue to fail after running cargo clean? The call stack suggests that this might be an incremental compilation bug.

@Aaron1011
Copy link
Member

This is a known incremental compilation bug, and should be fixed on the latest nightly.

@ChosunOne
Copy link
Author

@compiler-errors It failed after a rm -rf target, so I would assume that it would also fail on cargo clean.
@Aaron1011 Feel free to close the issue if you are sure this bug is already reported/known.

@heikki-heikkila
Copy link

@Aaron1011 , could you please give reference to that known bug, so I could see the exact nightly version where this is fixed?

@Aaron1011
Copy link
Member

There's been a large number of incremental compilation crash reportsz all with very similar messages and stacktraces. I think I initially misready the stacktrace for this issue - it was probably just fixed in #93064

Without the ability to reproduce these crashes, it's very hard to determine which of the many incremental compilation PRs will actually fix your issue. The best strategy is to update to the latest nightly - if the issue re-occurs, we'll know it's not caused by any of the bugs that were recently fixed.

@heikki-heikkila
Copy link

Regarding the advice from @Aaron1011, "The best strategy is to update to the latest nightly":

Indeed, I have a compiler crash case that happened when I used compiler "rustc 1.59.0-nightly (cfa4ac6 2022-01-06)" but disappered when I upgraded to "rustc 1.60.0-nightly (8cdb3cd 2022-01-25)". The case is too complicated to be described here -- it involves crate "okapi" and certain inherently nightly features -- but the symptoms are as above: build from scratch succeeds without issues but incremental compilation crashes with "#0 [codegen_fulfill_obligation] checking if core::ops::function::FnOnce fulfills its obligations".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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

5 participants