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

Broken MIR after compiler update when indexing statics with async values #66695

unneon opened this issue Nov 24, 2019 · 2 comments · Fixed by #66793

Broken MIR after compiler update when indexing statics with async values #66695

unneon opened this issue Nov 24, 2019 · 2 comments · Fixed by #66793
A-async-await A-generators C-bug glacier I-ICE P-high regression-from-stable-to-nightly T-compiler


Copy link

@unneon unneon commented Nov 24, 2019

I have some code which asynchronously computes an integer, and selects an item from a static slice in the same expression. This used to work (it does on stable), but after a nightly update the compiler ICEs when computing generator layout.

The bug stops reproducing if I change the static to a local variable, or extract the index into a separate variable.

static CODEGEN: &[()] = &[];

async fn manual() {
	CODEGEN[async { 0 }.await];
    Checking icie v0.6.4 (/home/matcegla/Projects/icie)
warning: static item is never used: `CODEGEN`
 --> src/
1 | static CODEGEN: &[()] = &[];
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: `#[warn(dead_code)]` on by default

warning: function is never used: `manual`
 --> src/
3 | async fn manual() {
  |          ^^^^^^

error: internal compiler error: src/librustc_mir/transform/ Broken MIR: generator contains type &&[()] in MIR, but typeck only knows about for<'r, 's> {&'r [()], &'s [()], [static generator@src/ 4:21 {}], impl std::future::Future, impl std::future::Future, ()}
 --> src/
3 |   async fn manual() {
  |  ___________________^
4 | |     CODEGEN[async { 0 }.await];
5 | | }
  | |_^

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/
   4: core::fmt::write
             at src/libcore/fmt/
   5: std::io::Write::write_fmt
             at src/libstd/io/
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/
   9: std::panicking::default_hook
             at src/libstd/
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::span_bug
  14: rustc_errors::Handler::span_bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::span_bug_fmt
  20: rustc_mir::transform::generator::compute_layout
  21: <rustc_mir::transform::generator::StateTransform as rustc_mir::transform::MirPass>::run_pass
  22: rustc_mir::transform::run_passes
  23: rustc_mir::transform::run_optimization_passes
  24: rustc_mir::transform::optimized_mir
  25: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  26: rustc::dep_graph::graph::DepGraph::with_task_impl
  27: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  28: rustc::ty::<impl rustc::ty::context::TyCtxt>::generator_layout
  29: <rustc_metadata::rmeta::encoder::EncodeContext as rustc::hir::intravisit::Visitor>::visit_expr
  30: rustc::hir::intravisit::walk_expr
  31: <rustc_metadata::rmeta::encoder::EncodeContext as rustc::hir::intravisit::Visitor>::visit_expr
  32: rustc::hir::intravisit::walk_item
  33: <rustc_metadata::rmeta::encoder::EncodeContext as rustc::hir::intravisit::Visitor>::visit_item
  34: rustc::hir::Crate::visit_all_item_likes
  35: rustc_metadata::rmeta::encoder::EncodeContext::encode_crate_root
  36: rustc::ty::context::tls::with_context::{{closure}}
  37: rustc_metadata::rmeta::encoder::encode_metadata
  38: rustc_metadata::rmeta::decoder::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::cstore::CStore>::encode_metadata
  39: rustc::ty::context::TyCtxt::encode_metadata
  40: rustc_interface::passes::start_codegen::{{closure}}
  41: rustc_interface::passes::start_codegen
  42: rustc::ty::context::tls::enter_global
  43: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  44: rustc_interface::passes::create_global_ctxt::{{closure}}
  45: rustc_interface::passes::BoxedGlobalCtxt::enter
  46: rustc_interface::queries::Query<T>::compute
  47: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
  48: rustc_interface::interface::run_compiler_in_existing_thread_pool
  49: std::thread::local::LocalKey<T>::with
  50: scoped_tls::ScopedKey<T>::set
  51: syntax::with_globals
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:

note: rustc 1.41.0-nightly (0c987c5c0 2019-11-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type cdylib --crate-type rlib

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

query stack during panic:
#0 [optimized_mir] processing `manual::{{closure}}#0`
end of query stack
error: aborting due to previous error

error: could not compile `icie`.

To learn more, run the command again with --verbose.

rustc 1.41.0-nightly (0c987c5 2019-11-23)
binary: rustc
commit-hash: 0c987c5
commit-date: 2019-11-23
host: x86_64-unknown-linux-gnu
release: 1.41.0-nightly
LLVM version: 9.0

@jonas-schievink jonas-schievink added A-async-await A-generators C-bug I-ICE I-nominated regression-from-stable-to-nightly T-compiler labels Nov 24, 2019
@matthewjasper matthewjasper self-assigned this Nov 24, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier label Nov 26, 2019
Copy link

@Mark-Simulacrum Mark-Simulacrum commented Nov 26, 2019

De-nominating from compiler team as we have a fix pending.

matthewjasper added a commit to matthewjasper/rust that referenced this issue Nov 27, 2019
matthewjasper added a commit to matthewjasper/rust that referenced this issue Nov 27, 2019
Copy link

@pnkfelix pnkfelix commented Nov 28, 2019

triage: P-high.

@pnkfelix pnkfelix added the P-high label Nov 28, 2019
RalfJung added a commit to RalfJung/rust that referenced this issue Nov 29, 2019

Record temporary static references in generator witnesses

Closes rust-lang#66695

* Record the pointer to static's type in MIR.
* Normalize the static's type (so that constants can be compared correctly).
0dvictor pushed a commit to 0dvictor/rust that referenced this issue Dec 1, 2019
9999years pushed a commit to 9999years/rust that referenced this issue Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
A-async-await A-generators C-bug glacier I-ICE P-high regression-from-stable-to-nightly T-compiler
None yet

Successfully merging a pull request may close this issue.

6 participants