rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.25k stars 12.71k forks source link

Compiler panic - More than one activation introduced at the same location (librustc_mir) #49701

Closed Redrield closed 5 years ago

Redrield commented 6 years ago

In working on small improvements to my toy compiler, I ran into a situation that is crashing rustc. The change happened after I updated my nightly to the latest in order to use clippy to clean up my project.

Rustc information

rustc 1.27.0-nightly (fb44b4c0e 2018-04-04) binary: rustc commit-hash: fb44b4c0eb1d344f84f7bb2c90f28e31a8a180be commit-date: 2018-04-04 host: x86_64-unknown-linux-gnu release: 1.27.0-nightly LLVM version: 6.0

Compilation output (using cargo build, RUST_BACKTRACE=full)

   Compiling oxyc v0.2.0 (file:///home/redrield/Documents/Programming/Rust/oxygen)
thread 'main' panicked at 'More than one activation introduced at the same location.', librustc_mir/dataflow/impls/borrows.rs:216:21
stack backtrace:
   0:     0x7ff5c8a30deb - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h5069b860fd89fede
                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7ff5c89fec90 - std::sys_common::backtrace::print::h72f7455d326d2b4a
                               at libstd/sys_common/backtrace.rs:71
                               at libstd/sys_common/backtrace.rs:59
   2:     0x7ff5c8a2453d - std::panicking::default_hook::{{closure}}::h6922013f10fcb7bc
                               at libstd/panicking.rs:207
   3:     0x7ff5c8a2429b - std::panicking::default_hook::hde1fe4aef69c9aad
                               at libstd/panicking.rs:223
   4:     0x7ff5c506273d - core::ops::function::Fn::call::hd32c0e0a01d4dd82
   5:     0x7ff5c8a24a89 - std::panicking::rust_panic_with_hook::h2d5d336ad08f3f08
                               at libstd/panicking.rs:403
   6:     0x7ff5c5bf5275 - std::panicking::begin_panic::h15194b971007d3ac
   7:     0x7ff5c5d208b5 - <rustc_mir::dataflow::impls::borrows::Borrows::new::GatherBorrows<'a, 'gcx, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_assign::h995165edc98c0387
   8:     0x7ff5c5d1f190 - rustc_mir::dataflow::impls::borrows::Borrows::new::hc161b00c74c34bb3
   9:     0x7ff5c5bd05b1 - rustc_mir::borrow_check::do_mir_borrowck::h75fc7d99522b40e1
  10:     0x7ff5c5b5c0a8 - <std::thread::local::LocalKey<T>>::with::hcccb5b5165c4ca57
  11:     0x7ff5c5c34098 - rustc::ty::context::GlobalCtxt::enter_local::hcb78b84632d28a14
  12:     0x7ff5c5bcf49c - rustc_mir::borrow_check::mir_borrowck::hbf0f21ed59d1b251
  13:     0x7ff5c4f7b8cf - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::compute_result::h463cd69eae961311
  14:     0x7ff5c4c1b500 - rustc::dep_graph::graph::DepGraph::with_task_impl::h8f92aed29349cf72
  15:     0x7ff5c4c73bfc - rustc_errors::Handler::track_diagnostics::h2dce3cc01f7a05f0
  16:     0x7ff5c4edc247 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::h99ac0a7d95c18ed7
  17:     0x7ff5c4f7b966 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::force::h5f447daf2bc95ea2
  18:     0x7ff5c4f7c200 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::try_get::h633bedd235bb0e0a
  19:     0x7ff5c4f2a51e - rustc::ty::maps::TyCtxtAt::mir_borrowck::hbe9b48380c92a3d2
  20:     0x7ff5c4f26cc8 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_borrowck::h3b76f5545edaeb68
  21:     0x7ff5c8dc2413 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::{{closure}}::hfe9c26f5ed773e4a
  22:     0x7ff5c8e34fca - <std::thread::local::LocalKey<T>>::with::h0d1ae540272e2200
  23:     0x7ff5c8e36f56 - <std::thread::local::LocalKey<T>>::with::h513bd6069552146c
  24:     0x7ff5c8eaf1ce - rustc::ty::context::TyCtxt::create_and_enter::he369d7838683c297
  25:     0x7ff5c8da7bf7 - rustc_driver::driver::compile_input::h586a1e77f042c5d8
  26:     0x7ff5c8e5b0be - rustc_driver::run_compiler_impl::h03c277a2883adc5e
  27:     0x7ff5c8da4da8 - syntax::with_globals::h59bb344781334418
  28:     0x7ff5c8e57f9d - rustc_driver::run::he7549a7e67a0d61e
  29:     0x7ff5c8e6767a - rustc_driver::main::h52e6afb3c5e5b668
  30:     0x55f85726bfd2 - std::rt::lang_start::{{closure}}::h26b9a7fcd10f4c6a
  31:     0x7ff5c8a24707 - std::panicking::try::do_call::h670848ae8b8bcd01
                               at libstd/rt.rs:59
                               at libstd/panicking.rs:306
  32:     0x7ff5c8a3f3ee - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:102
  33:     0x7ff5c89f2f85 - std::rt::lang_start_internal::he30958e08409b1f9
                               at libstd/panicking.rs:285
                               at libstd/panic.rs:361
                               at libstd/rt.rs:58
  34:     0x55f85726c033 - main
  35:     0x7ff5c8610f49 - __libc_start_main
  36:     0x55f85726beb8 - <unknown>
error: Could not compile `oxyc`.

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

Other notes

This error seems to be a regression from nightly-2018-04-03 to more recent nightlies. nightly-2018-04-03 is the latest nightly in which the compiler does not panic.

The normal message reporting a compiler panic and detailing how to report it is not being shown in multiple compilation attempts on my machine.

fintelia commented 6 years ago

I am observing the same behavior on the latest nightly when trying to compile distributary.

golddranks commented 6 years ago

I'm getting the same ICE when compiling my Stream Zipper library: https://github.com/golddranks/stream_zipper

Testing with the nightly-2018-04-03 to see if this is the same bug or not.

golddranks commented 6 years ago

Confirmation: this commit ( https://github.com/golddranks/stream_zipper/commit/1c47480a7159215515756b2941989f20b9f4b932 ) builds with nightly-2018-04-03, fails with anything newer.

Redrield commented 6 years ago

With this environment the program stops crashing, should the issue be closed?

rustc 1.27.0-nightly (acd3871ba 2018-05-10)
binary: rustc
commit-hash: acd3871ba17316419c644e17547887787628ec2f
commit-date: 2018-05-10
host: x86_64-unknown-linux-gnu
release: 1.27.0-nightly
LLVM version: 6.0
varkor commented 5 years ago

It would be nice to get a test case for this, but considering how long ago this was, it might be difficult to minimise a test case we can confirm. I'm going to close as fixed, but we can re-open if this rears its head again.