Rust: ICE on borrow check `check_loans` on stable

Created on 27 Aug 2019  路  9Comments  路  Source: rust-lang/rust

I don't know how to minimize this...

$ RUST_BACKTRACE=1 cargo run
   Compiling baguetteland v0.1.0 (/nobackup/baguetteland)
thread 'rustc' panicked at 'assertion failed: self.bccx.region_scope_tree.scopes_intersect(old_loan.kill_scope,
                                             new_loan.kill_scope)', src/librustc_borrowck/borrowck/check_loans.rs:493:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   8: std::panicking::begin_panic
   9: rustc_borrowck::borrowck::check_loans::CheckLoanCtxt::report_error_if_loans_conflict
  10: rustc_borrowck::dataflow::DataFlowContext<O>::each_bit_on_entry
  11: <rustc_borrowck::borrowck::check_loans::CheckLoanCtxt as rustc::middle::expr_use_visitor::Delegate>::borrow
  12: rustc::middle::expr_use_visitor::ExprUseVisitor::borrow_expr
  13: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
  14: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr
  15: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
  16: rustc::middle::expr_use_visitor::ExprUseVisitor::borrow_expr
  17: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
  18: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr
  19: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
  20: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr
  21: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
  22: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr
  23: rustc_borrowck::borrowck::check_loans::check_loans
  24: rustc_borrowck::borrowck::borrowck
  25: rustc::ty::query::__query_compute::borrowck
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::borrowck>::compute
  27: rustc::dep_graph::graph::DepGraph::with_task_impl
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  29: rustc_mir::borrow_check::do_mir_borrowck
  30: rustc::ty::context::GlobalCtxt::enter_local
  31: rustc_mir::borrow_check::mir_borrowck
  32: rustc::ty::query::__query_compute::mir_borrowck
  33: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute
  34: rustc::dep_graph::graph::DepGraph::with_task_impl
  35: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  36: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  37: rustc::util::common::time
  38: rustc_interface::passes::analysis
  39: rustc::ty::query::__query_compute::analysis
  40: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  41: rustc::dep_graph::graph::DepGraph::with_task_impl
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  43: rustc::ty::context::tls::enter_global
  44: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  45: rustc_interface::passes::create_global_ctxt::{{closure}}
  46: rustc_interface::interface::run_compiler_in_existing_thread_pool
  47: std::thread::local::LocalKey<T>::with
  48: scoped_tls::ScopedKey<T>::set
  49: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [borrowck] processing `main`
#1 [mir_borrowck] processing `main`
#2 [analysis] running analysis passes on this crate
end of query stack

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.37.0 (eae3437df 2019-08-13) running on x86_64-unknown-linux-gnu

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

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

error: Could not compile `baguetteland`.

To learn more, run the command again with --verbose.
A-borrow-checker C-bug I-ICE I-nominated T-compiler

Most helpful comment

@varkor the test was added in pr that fixed this bug: https://github.com/rust-lang/rust/pull/62233

All 9 comments

Does the ICE occur on nightly?
Based on the failed assert, it might have already been fixed by #62233

cc @matthewjasper

struct Inventory;

impl Inventory {
    pub fn index(&self) -> &bool {
        &true
    }
}

fn main() {
    let game_state = Inventory;

    loop {
        match game_state {
            ref inventory if *inventory.index() => {}
            ref inventory if *inventory.index() => {}
            ref mut inventory => {}
        }
    }
}

Minimal reproduction on stable...

It does not appear to happen on a recent nightly:

$ rustc +nightly --version
rustc 1.39.0-nightly (f7af19c27 2019-08-15)

It doesn't appear on beta either.

Ostensibly we could do a point release but I'm thinking that's unlikely as this only makes an ICE into an error.

It seems like it would be ok to just let the beta promote... Perhaps we can wait and see. If more people run into this, it might be worth fixing. Otherwise, I would just wait it out.

@varkor the test was added in pr that fixed this bug: https://github.com/rust-lang/rust/pull/62233

Check-in from compiler triage:

This bug exists on stable but has been fixed on beta/nightly and is not considered high priority. I'm going to close the issue as fixed for now. Thanks for the report!

Was this page helpful?
0 / 5 - 0 ratings