Skip to content

Compiler panic related cause by NLLs #47153

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

Closed
71 opened this issue Jan 3, 2018 · 9 comments
Closed

Compiler panic related cause by NLLs #47153

71 opened this issue Jan 3, 2018 · 9 comments
Labels
A-NLL Area: Non-lexical lifetimes (NLL) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@71
Copy link
Contributor

71 commented Jan 3, 2018

When compiling a project with #[feature(nll)] enabled, rustc panics because of a failed assertion.

My project has many errors so I can't determine exactly what code is causing a problem; I'll update when I'll know more.

Backtrace

note: rustc 1.24.0-nightly (687d3d15b 2018-01-02) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'assertion failed: identity_substs.is_empty()', /checkout/src/librustc_mir/borrow_check/nll/universal_regions.rs:593:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at /checkout/src/libstd/sys_common/backtrace.rs:68
             at /checkout/src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
   6: rustc_mir::borrow_check::nll::universal_regions::UniversalRegions::new
   7: rustc_mir::borrow_check::nll::replace_regions_in_mir
   8: rustc_mir::borrow_check::do_mir_borrowck
   9: rustc::ty::context::tls::enter
  10: rustc::infer::InferCtxtBuilder::enter
  11: rustc_mir::borrow_check::mir_borrowck
  12: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::compute_result
  13: rustc::dep_graph::graph::DepGraph::with_task_impl
  14: rustc_errors::Handler::track_diagnostics
  15: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  16: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::force
  17: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::try_get
  18: rustc::ty::maps::TyCtxtAt::mir_borrowck
  19: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_borrowck
  20: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::{{closure}}
  21: <std::thread::local::LocalKey<T>>::with
  22: <std::thread::local::LocalKey<T>>::with
  23: rustc::ty::context::TyCtxt::create_and_enter
  24: rustc_driver::driver::compile_input
  25: rustc_driver::run_compiler

Version

rustc 1.24.0-nightly (687d3d15b 2018-01-02)
binary: rustc
commit-hash: 687d3d15ba726dbb1ac6b85223ebe0e98c6820cc
commit-date: 2018-01-02
host: x86_64-unknown-linux-gnu
release: 1.24.0-nightly
LLVM version: 4.0
@nikomatsakis nikomatsakis added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-compiler-nll labels Jan 3, 2018
@nikomatsakis
Copy link
Contributor

Can you give any sort of link to code that reproduces the problem?

@71
Copy link
Contributor Author

71 commented Jan 6, 2018

I tried fixing the project to determine what exactly caused the issue, but couldn't find exactly what code was doing this. If no similar issue is encountered, I can try rolling back my old code and see if I can make it crash again.

@pnkfelix pnkfelix added the A-NLL Area: Non-lexical lifetimes (NLL) label Jan 10, 2018
@nikomatsakis
Copy link
Contributor

I don't recall seeing any similar ICEs.

@mtanski
Copy link

mtanski commented Jan 16, 2018

Ran into this bug here: https://github.com/mtanski/dbkit/tree/nll-build-crash

Regular build (cargo build) doesn't crash it, but building test code (cargo test) does.

Could not slim down the test case. Attempts at it make the bug go away.

Version

mtanski@crunchy:~/src/dbkit$ rustup show
Default host: x86_64-unknown-linux-gnu

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.25.0-nightly (79a521bb9 2018-01-15)

Crash
Travis link: https://travis-ci.org/mtanski/dbkit/builds/329507232?utm_source=email&utm_medium=notification

mtanski@crunchy:~/src/dbkit$ RUST_BACKTRACE=1 cargo test
   Compiling dbkit-engine v0.0.9 (file:///home/mtanski/src/dbkit)

...

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.25.0-nightly (79a521bb9 2018-01-15) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'assertion failed: identity_substs.is_empty()', librustc_mir/borrow_check/nll/universal_regions.rs:593:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:68
             at libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:380
   3: std::panicking::default_hook
             at libstd/panicking.rs:390
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:576
   5: std::panicking::begin_panic
   6: rustc_mir::borrow_check::nll::universal_regions::UniversalRegions::new
   7: rustc::ty::context::tls::enter
   8: rustc::infer::InferCtxtBuilder::enter
   9: rustc_mir::borrow_check::mir_borrowck
  10: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::compute_result
  11: rustc::dep_graph::graph::DepGraph::with_task_impl
  12: rustc_errors::Handler::track_diagnostics
  13: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  14: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::force
  15: rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::try_get
  16: rustc::ty::maps::TyCtxtAt::mir_borrowck
  17: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_borrowck
  18: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::{{closure}}
  19: <std::thread::local::LocalKey<T>>::with
  20: <std::thread::local::LocalKey<T>>::with
  21: rustc::ty::context::TyCtxt::create_and_enter
  22: rustc_driver::driver::compile_input
  23: rustc_driver::run_compiler

error: Could not compile `dbkit-engine`.

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

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jan 16, 2018

Minimized example:

#![feature(nll)]

trait Foo {
    const B: bool = true;
}

fn main() { }

Another example:

#![feature(nll)]

struct Foo<T> { x: T }

impl<T> Foo<T> {
    const B: bool = true;
}

fn main() { }

@nikomatsakis
Copy link
Contributor

The problem is this assertion is firing:

assert!(identity_substs.is_empty());

My assumption in writing that code was that constant values were never generic. But that was simply not true, as these examples show. I suspect we can just remove the assertion, actually, though I'm trying to see if this was important for some other reason.

@Pulkit07
Copy link
Contributor

Thanks @nikomatsakis for helping in breaking down the bug, I will take care of this.

@nikomatsakis
Copy link
Contributor

@Pulkit07 too late ;)

@Pulkit07
Copy link
Contributor

@nikomatsakis hehe, no worries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants