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

ICE with #![feature(const_loop)] static _X: () = loop {}; #70723

Closed
Centril opened this issue Apr 2, 2020 · 3 comments · Fixed by #70771
Closed

ICE with #![feature(const_loop)] static _X: () = loop {}; #70723

Centril opened this issue Apr 2, 2020 · 3 comments · Fixed by #70771
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-miri Area: The miri tool 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-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril commented Apr 2, 2020

Code

#![feature(const_loop)]

static _X: () = loop {};

Also reproduces with const or static mut (add those in a regression test!).

Meta

note: rustc 1.44.0-nightly (76b1198 2020-04-01) running on x86_64-unknown-linux-gnu

Error output

   Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at 'assertion failed: self.cur_frame() != old_stack || self.frame().block != old_bb', src/librustc_mir/interpret/step.rs:288:13
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1439
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:515
  12: std::panicking::begin_panic
  13: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  14: rustc_mir::const_eval::eval_queries::const_eval_raw_provider
  15: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_raw>::compute
  16: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  17: rustc_query_system::query::plumbing::get_query
  18: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
  19: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_validated>::compute
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  21: rustc_query_system::query::plumbing::get_query
  22: rustc_mir::const_eval::eval_queries::const_eval_validated_provider
  23: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_validated>::compute
  24: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  25: rustc_query_system::query::plumbing::get_query
  26: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  27: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_poly
  28: <rustc_lint::BuiltinCombinedLateLintPass as rustc_lint::passes::LateLintPass>::check_item
  29: rustc_hir::intravisit::Visitor::visit_nested_item
  30: rustc_hir::intravisit::walk_crate
  31: rustc_lint::late::late_lint_crate
  32: rustc_data_structures::sync::join
  33: rustc_interface::passes::analysis::{{closure}}::{{closure}}
  34: rustc_session::utils::<impl rustc_session::session::Session>::time
  35: rustc_interface::passes::analysis
  36: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  37: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  38: rustc_query_system::query::plumbing::get_query
  39: rustc_middle::ty::context::tls::enter_global
  40: rustc_interface::interface::run_compiler_in_existing_thread_pool
  41: scoped_tls::ScopedKey<T>::set
  42: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.44.0-nightly (76b11980a 2020-04-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

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

query stack during panic:
#0 [const_eval_raw] const-evaluating `_X`
#1 [const_eval_validated] const-evaluating + checking `_X`
#2 [const_eval_validated] const-evaluating + checking `_X`
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground`.
@Centril Centril added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. F-const_loop labels Apr 2, 2020
@Centril
Copy link
Contributor Author

Centril commented Apr 2, 2020

cc @RalfJung @oli-obk

@Centril Centril added the A-const-eval Area: Constant evaluation (MIR interpretation) label Apr 2, 2020
@Centril Centril changed the title ICE with static _X: () = loop {}; ICE with #![feature(const_loop)] static _X: () = loop {}; Apr 2, 2020
@RalfJung
Copy link
Member

RalfJung commented Apr 3, 2020

Miri reproducer:

fn main() {
    loop {}
}

This is running into a sanity check that I added to avoid mistakes in the engine where we forget to correctly handle a MIR Terminator. Those bugs happened before and lead to rather annoying to debug infinite loops in rustc.

However, my hypothesis here is that the MIR is such that even a correct handling of the Terminator does not change the machine state at all. I thought there would always be something that changes, but here we have:

    bb1: {
        goto -> bb1;                     // bb1[0]: scope 0 at src/main.rs:2:5: 2:12
    }

The easiest fix to to just get rid of that assertion. I wonder if there is a way to salvage the sanity check though. Would be good to keep it for function calls, at least.

@RalfJung
Copy link
Member

RalfJung commented Apr 4, 2020

Fix PR is up: #70771

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) A-miri Area: The miri tool 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-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. 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.

3 participants