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

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

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

unneon opened this issue Nov 24, 2019 · 2 comments · Fixed by #66793
Assignees
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High 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

@unneon
Copy link

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/lib.rs:1:1
  |
1 | static CODEGEN: &[()] = &[];
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

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

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

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:851:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1030
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:188
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:205
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:468
  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: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

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 Area: Async & Await A-coroutines Area: Coroutines C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated 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. labels Nov 24, 2019
@matthewjasper matthewjasper self-assigned this Nov 24, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Nov 26, 2019
@Mark-Simulacrum
Copy link
Member

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
@pnkfelix
Copy link
Member

triage: P-high.

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

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).
@bors bors closed this as completed in 37c1f52 Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High 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