Repository navigation
Compiler panic on fairly simple match expression #51415
Copy link
Copy link
Closed
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
Here's the stack trace
> make build
PKG_CONFIG_ALLOW_CROSS=1 \
RUSTFLAGS='-D warnings' \
RUST_BACKTRACE=1 \
cargo build --target "x86_64-unknown-linux-gnu"
Compiling libstratis v0.5.3 (file:///home/mulhern/my-contributions/stratisd)
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: (MoveData { move_paths: [MovePath { place: _0 }, MovePath { place: _1 }, MovePath { place: _2 }, MovePath { place: _3 }, MovePath { place: _4 }], moves: [mp4@bb0[4], mp4@bb2[0], mp3@bb2[1], mp3@bb3[0], mp3@bb4[0], mp0@bb4[1]], loc_map: LocationMap { map: [[[], [], [], [], [mo0]], [[]], [[mo1], [mo2]], [[mo3]], [[mo4], [mo5]]] }, path_map: [[mo5], [], [], [mo2, mo3, mo4], [mo0, mo1]], rev_lookup: MovePathLookup { locals: [mp0, mp1, mp2, mp3, mp4], projections: {} }, inits: [mp1@src/engine/strat_engine/cmd.rs:54:32: 54:59 (Deep), mp2@src/engine/strat_engine/cmd.rs:54:33: 54:43 (Deep), mp3@src/engine/strat_engine/cmd.rs:54:38: 54:42 (Deep), mp4@src/engine/strat_engine/cmd.rs:54:45: 54:49 (Deep), mp0@src/engine/strat_engine/cmd.rs:54:45: 54:59 (NonPanicPathOnly)], init_loc_map: LocationMap { map: [[[], [in2], [], [in3], [in4]], [[]], [[], []], [[]], [[], []]] }, init_path_map: [[in4], [in0], [in1], [in2], [in3]] }, [IllegalMove { cannot_move_out_of: IllegalMoveOrigin { span: src/engine/strat_engine/cmd.rs:54:38: 54:42, kind: BorrowedContent } }])', libcore/result.rs:945:5
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
1: std::sys_common::backtrace::print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: core::ops::function::Fn::call
5: std::panicking::rust_panic_with_hook
6: std::panicking::begin_panic_fmt
7: rust_begin_unwind
8: core::panicking::panic_fmt
9: core::result::unwrap_failed
10: <rustc_mir::transform::elaborate_drops::ElaborateDrops as rustc_mir::transform::MirPass>::run_pass
11: rustc_mir::transform::optimized_mir::{{closure}}
12: rustc_mir::transform::optimized_mir
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::optimized_mir<'tcx>>::force
17: rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::try_get
18: rustc::ty::maps::TyCtxtAt::optimized_mir
19: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::optimized_mir
20: rustc_metadata::encoder::<impl rustc_metadata::isolated_encoder::IsolatedEncoder<'a, 'b, 'tcx>>::encode_optimized_mir
21: rustc_metadata::encoder::<impl rustc_metadata::isolated_encoder::IsolatedEncoder<'a, 'b, 'tcx>>::encode_info_for_closure
22: rustc::dep_graph::graph::DepGraph::with_ignore
23: rustc_metadata::encoder::<impl rustc_metadata::index_builder::IndexBuilder<'a, 'b, 'tcx>>::encode_info_for_expr
24: rustc::hir::intravisit::walk_expr
25: rustc::hir::intravisit::walk_expr
26: rustc::hir::intravisit::walk_expr
27: rustc::hir::intravisit::Visitor::visit_nested_body
28: <rustc_metadata::encoder::EncodeVisitor<'a, 'b, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
29: rustc::hir::Crate::visit_all_item_likes
30: rustc_metadata::encoder::encode_metadata
31: rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::cstore::CStore>::encode_metadata
32: rustc::ty::context::TyCtxt::encode_metadata
33: rustc_trans::base::write_metadata
34: rustc::util::common::time
35: rustc_trans::base::trans_crate
36: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
37: rustc::util::common::time
38: rustc_driver::driver::phase_4_translate_to_llvm
39: rustc_driver::driver::compile_input::{{closure}}
40: <std::thread::local::LocalKey<T>>::with
41: <std::thread::local::LocalKey<T>>::with
42: rustc::ty::context::TyCtxt::create_and_enter
43: rustc_driver::driver::compile_input
44: rustc_driver::run_compiler_impl
45: syntax::with_globals
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.26.0 running on x86_64-unknown-linux-gnu
note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `libstratis`.
To learn more, run the command again with --verbose.
make: *** [Makefile:27: build] Error 101
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Activity
mulkieran commentedon Jun 7, 2018
Here's a PR with the code that caused the crash:
stratis-storage/stratisd#983
mulkieran commentedon Jun 7, 2018
I compile frequently, and had made only a few changes between this and the last time I had compiled. I think the crash has something to do with the implementation of
verify_binariesbecause I had just been juggling with that. I expect it has something to do with theSomematch arm.hellow554 commentedon Jun 7, 2018
Can you provide a mcve?
mulkieran commentedon Jun 7, 2018
What's an "mcve"?
mulkieran commentedon Jun 7, 2018
Whoops, I thought that was an actual word, not an initialism. Giving it the 15 minute try...
mulkieran commentedon Jun 7, 2018
Well, I make no assertions about minimality, but this code snippet does fail on the rust playground w/ all six possible configurations and it's pretty short.
mulkieran commentedon Jun 7, 2018
Smaller:
mulkieran commentedon Jun 7, 2018
Smidge smaller:
hellow554 commentedon Jun 7, 2018
ICE does not happen with
#![feature(nll)]hellow554 commentedon Jun 7, 2018
You can make your example working by changing the
&pathto eitherpath(match ergnomics) orref path(explicit ref), but yes. You're right. It's an ICE, should not happen :)hellow554 commentedon Jun 7, 2018
Worked on 1.25.0 with an explicit error message.
estebank commentedon Jun 7, 2018
I think might have been caused by the match ergonomics pr.
alberdingk-thijm commentedon Jun 21, 2018
Had a similar compiler panic with this snippet of code:
Changing it to the snippet below fixes the problem, so I definitely think the match ergonomics is doing something.
See it in the playground here.
nikomatsakis commentedon Jun 21, 2018
triage: P-high
Hmm, this might be a problem with borrowck failing to catch a borrow (the NLL borrow checker seems to catch the error correctly).
nikomatsakis commentedon Jun 21, 2018
The problem seems to be specific to argument patterns. This code fails to compile as expected:
Auto merge of #51686 - nikomatsakis:issue-51415-borrowck-match-defaul…