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

Regression in nightly-2020-07-22: collection encountered polymorphic constant #74614

Closed
dtolnay opened this issue Jul 22, 2020 · 4 comments · Fixed by #74633
Closed

Regression in nightly-2020-07-22: collection encountered polymorphic constant #74614

dtolnay opened this issue Jul 22, 2020 · 4 comments · Fixed by #74633
Assignees
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dtolnay
Copy link
Member

dtolnay commented Jul 22, 2020

The widely used reqwest crate began failing to compile in nightly-2020-07-22. To reproduce, clone https://github.com/seanmonstar/reqwest/tree/69288606bcf648967ddd09000f06e88161f80a2f and run cargo build.

error: internal compiler error: src/librustc_mir/monomorphize/collector.rs:629:54: collection encountered polymorphic constant
  --> /home/david/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/raw.rs:30:1
   |
30 | / pub(super) fn vtable<T: Future, S: Schedule>() -> &'static Vtable {
31 | |     &Vtable {
32 | |         poll: poll::<T, S>,
33 | |         dealloc: dealloc::<T, S>,
...  |
37 | |     }
38 | | }
   | |_^

Note the error is presented on tokio-0.2.22 but that crate compiles fine by itself. Running cargo build again indicates it's only reqwest being compiled when the ICE occurs.

Complete error and backtrace
$ RUST_BACKTRACE=1 cargo +nightly-2020-07-22 build
   Compiling reqwest v0.10.6 (/git/tmp/reqwest)
error: internal compiler error: src/librustc_mir/monomorphize/collector.rs:629:54: collection encountered polymorphic constant
  --> /home/david/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/task/raw.rs:30:1
   |
30 | / pub(super) fn vtable<T: Future, S: Schedule>() -> &'static Vtable {
31 | |     &Vtable {
32 | |         poll: poll::<T, S>,
33 | |         dealloc: dealloc::<T, S>,
...  |
37 | |     }
38 | | }
   | |_^

thread 'rustc' panicked at 'Box<Any>', /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/macros.rs:13:23
stack backtrace:
   0: std::backtrace_rs::backtrace::libunwind::trace
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/../backtrace/src/backtrace/libunwind.rs:96
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/../backtrace/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/sys_common/backtrace.rs:58
   4: core::fmt::write
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libcore/fmt/mod.rs:1117
   5: std::io::Write::write_fmt
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/io/mod.rs:1508
   6: std::sys_common::backtrace::_print
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/sys_common/backtrace.rs:61
   7: std::sys_common::backtrace::print
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/sys_common/backtrace.rs:48
   8: std::panicking::default_hook::{{closure}}
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/panicking.rs:217
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at /rustc/8ad7bc3f428300aee6764f6e23527e19eb235e81/src/libstd/panicking.rs:530
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::span_bug
  14: rustc_errors::Handler::span_bug
  15: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc_middle::ty::context::tls::with_opt::{{closure}}
  17: rustc_middle::ty::context::tls::with_opt
  18: rustc_middle::util::bug::opt_span_bug_fmt
  19: rustc_middle::util::bug::span_bug_fmt
  20: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_const
  21: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_rvalue
  22: rustc_mir::monomorphize::collector::collect_neighbours
  23: rustc_mir::monomorphize::collector::collect_items_rec
  24: rustc_mir::monomorphize::collector::collect_items_rec
  25: rustc_mir::monomorphize::collector::collect_items_rec
  26: rustc_mir::monomorphize::collector::collect_items_rec
  27: rustc_mir::monomorphize::collector::collect_items_rec
  28: rustc_mir::monomorphize::collector::collect_items_rec
  29: rustc_mir::monomorphize::collector::collect_items_rec
  30: rustc_mir::monomorphize::collector::collect_items_rec
  31: rustc_mir::monomorphize::collector::collect_items_rec
  32: rustc_mir::monomorphize::collector::collect_items_rec
  33: rustc_mir::monomorphize::collector::collect_items_rec
  34: rustc_mir::monomorphize::collector::collect_items_rec
  35: rustc_mir::monomorphize::collector::collect_items_rec
  36: rustc_mir::monomorphize::collector::collect_items_rec
  37: rustc_mir::monomorphize::collector::collect_items_rec
  38: rustc_mir::monomorphize::collector::collect_items_rec
  39: rustc_mir::monomorphize::collector::collect_items_rec
  40: rustc_mir::monomorphize::collector::collect_items_rec
  41: rustc_mir::monomorphize::collector::collect_items_rec
  42: rustc_mir::monomorphize::collector::collect_items_rec
  43: rustc_mir::monomorphize::collector::collect_items_rec
  44: rustc_mir::monomorphize::collector::collect_items_rec
  45: rustc_mir::monomorphize::collector::collect_items_rec
  46: rustc_mir::monomorphize::collector::collect_items_rec
  47: rustc_mir::monomorphize::collector::collect_items_rec
  48: rustc_mir::monomorphize::collector::collect_items_rec
  49: rustc_mir::monomorphize::collector::collect_items_rec
  50: rustc_session::utils::<impl rustc_session::session::Session>::time
  51: rustc_mir::monomorphize::collector::collect_crate_mono_items
  52: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  53: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::collect_and_partition_mono_items>::compute
  54: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  55: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  56: rustc_data_structures::stack::ensure_sufficient_stack
  57: rustc_query_system::query::plumbing::get_query_impl
  58: rustc_codegen_ssa::back::symbol_export::exported_symbols_provider_local
  59: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::exported_symbols>::compute
  60: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  61: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  62: rustc_data_structures::stack::ensure_sufficient_stack
  63: rustc_query_system::query::plumbing::get_query_impl
  64: rustc_metadata::rmeta::encoder::encode_metadata_impl
  65: rustc_data_structures::sync::join
  66: rustc_metadata::rmeta::decoder::cstore_impl::<impl rustc_middle::middle::cstore::CrateStore for rustc_metadata::creader::CStore>::encode_metadata
  67: rustc_middle::ty::context::TyCtxt::encode_metadata
  68: rustc_interface::passes::start_codegen
  69: rustc_middle::ty::context::tls::enter_global
  70: rustc_interface::queries::Queries::ongoing_codegen
  71: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  72: rustc_span::with_source_map
  73: rustc_interface::interface::create_compiler_and_run
  74: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.47.0-nightly (8ad7bc3f4 2020-07-21) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
#1 [exported_symbols] exported_symbols
end of query stack
error: aborting due to previous error

error: could not compile `reqwest`.

To learn more, run the command again with --verbose.
@dtolnay dtolnay added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jul 22, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 22, 2020
dtolnay added a commit to dtolnay/syn that referenced this issue Jul 22, 2020
@JohnTitor JohnTitor added E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jul 22, 2020
@JohnTitor
Copy link
Member

I think the culprit PR is #69749 (and this is the first failure of "Polymorphization"), cc @davidtwco

@link2xt
Copy link

link2xt commented Jul 22, 2020

Same bug encountered here: deltachat/deltachat-core-rust#1743

@davidtwco davidtwco self-assigned this Jul 22, 2020
@JohnTitor JohnTitor removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jul 22, 2020
@eddyb
Copy link
Member

eddyb commented Jul 22, 2020

Huh the code that emits the ICE is kind of broken in terms of user expectations:

ty::ConstKind::Unevaluated(def, substs, promoted) => {
match self.tcx.const_eval_resolve(param_env, def, substs, promoted, None) {
Ok(val) => collect_const_value(self.tcx, val, self.output),
Err(ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted) => {}
Err(ErrorHandled::TooGeneric) => span_bug!(
self.tcx.def_span(def.did),
"collection encountered polymorphic constant",

It found a constant vtable::<T, S> (or more likely vtable::<T, S>::promoted0) somewhere but the Span it uses isn't that of the use site (self.body.source_info(location).span), but rather the definition site of the constant (fn vtable).

IMO it should print the constant (as part of the message), but use the use site span as the ICE span. Printing the ty::Const and not the DefId will ensure that the generic parameters are shown, which should help with debugging bugs like this.

@JohnTitor
Copy link
Member

Assigning P-critical as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

davidtwco added a commit to davidtwco/rust that referenced this issue Jul 22, 2020
This commit adds a regression test for rust-lang#74614 so that it is fixed before
polymorphisation is re-enabled.

Signed-off-by: David Wood <david@davidtw.co>
@bors bors closed this as completed in bbebe73 Jul 22, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 24, 2020
polymorphize GlobalAlloc::Function

this sadly does not change rust-lang#74614

r? @eddyb
dtolnay added a commit to dtolnay/syn that referenced this issue Jul 27, 2020
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. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants