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

Borrow Checker Paniced Upon Gifted Code #80767

Closed
tommythorn opened this issue Jan 7, 2021 · 4 comments · Fixed by #80404
Closed

Borrow Checker Paniced Upon Gifted Code #80767

tommythorn opened this issue Jan 7, 2021 · 4 comments · Fixed by #80404
Labels
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 regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tommythorn
Copy link

"Look Pal, it's either borrowed or taken. No gifting or buying stuff here."

Code

type G<'a> = [(O, &'a [u8]); 64];
enum O {O1}
fn main() {let p: [G; 4]; let _g: G = [(O::O1, &[]); 64]; f(p);}
fn f(_p: [G; 4]) {}

Meta

It reproduces on nightly and two other versions

rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-unknown-linux-gnu
release: 1.49.0

Error output


Backtrace

RUST_BACKTRACE=1 cargo build
   Compiling edgesim v0.1.0 (/Users/tommy/projects/Rust/edgesim)
thread 'rustc' panicked at 'assertion failed: promoted.is_none()', compiler/rustc_mir/src/transform/check_consts/qualifs.rs:254:9
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: rustc_mir::transform::check_consts::qualifs::in_operand
   4: rustc_mir::transform::promote_consts::Validator::qualif_local
   5: rustc_mir::transform::promote_consts::Validator::validate_ref
   6: rustc_mir::transform::promote_consts::Validator::validate_local
   7: rustc_mir::transform::promote_consts::Validator::validate_local
   8: rustc_mir::transform::promote_consts::Validator::validate_local
   9: rustc_mir::transform::promote_consts::Validator::validate_local
  10: rustc_mir::transform::promote_consts::should_suggest_const_in_array_repeat_expressions_attribute
  11: rustc_mir::borrow_check::type_check::TypeChecker::check_rvalue
  12: rustc_mir::borrow_check::type_check::TypeChecker::typeck_mir
  13: rustc_mir::borrow_check::type_check::type_check
  14: rustc_mir::borrow_check::nll::compute_regions
  15: rustc_mir::borrow_check::do_mir_borrowck
  16: rustc_infer::infer::InferCtxtBuilder::enter
  17: rustc_mir::borrow_check::mir_borrowck
  18: core::ops::function::FnOnce::call_once
  19: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
  20: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  21: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  22: rustc_data_structures::stack::ensure_sufficient_stack
  23: rustc_query_system::query::plumbing::get_query_impl
  24: rustc_query_system::query::plumbing::ensure_query_impl
  25: rustc_session::utils::<impl rustc_session::session::Session>::time
  26: rustc_interface::passes::analysis
  27: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  28: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: rustc_query_system::query::plumbing::get_query_impl
  32: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  33: rustc_span::with_source_map
  34: rustc_interface::interface::create_compiler_and_run
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0-nightly (da305a2b0 2021-01-05) running on aarch64-apple-darwin

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

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

@tommythorn tommythorn added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 7, 2021
@tesuji
Copy link
Contributor

tesuji commented Jan 7, 2021

This is a stable-to-stable regression. https://rust.godbolt.org/z/Kr7Peh
Have been happened from Rust 1.40 onwards.
error -> ICE : Could be P-low or P-medium

ICE happened here:

@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 7, 2021
@tesuji
Copy link
Contributor

tesuji commented Jan 7, 2021

Regression commit between 2019-10-29 and 2019-10-30
fetching (via local git) commits from b497e18...aa69777
found 7 bors merge commits in the specified range
commit[0] 2019-10-28UTC: Auto merge of #65202 - pietroalbini:scriptify-ci-config, r=alexcrichton
commit[1] 2019-10-28UTC: Auto merge of #65907 - Centril:rollup-9i8ev23, r=Centril
commit[2] 2019-10-29UTC: Auto merge of #65919 - Centril:rollup-qrgwnt6, r=Centril
commit[3] 2019-10-29UTC: Auto merge of #65435 - michaelwoerister:fix-issue-64153, r=alexcrichton
commit[4] 2019-10-29UTC: Auto merge of #65927 - eddyb:eval-always-considered-harmful, r=michaelwoerister
commit[5] 2019-10-29UTC: Auto merge of #65904 - matthiaskrgr:submodule_upd, r=Manishearth
commit[6] 2019-10-29UTC: Auto merge of #65943 - tmandry:rollup-g20uvkh, r=tmandry

Bisected using command:

cargo-bisect-rustc --start 2019-08-13 --end $(date --iso) --preserve --regress=ice -- check

@apiraino apiraino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 7, 2021
@apiraino
Copy link
Contributor

apiraino commented Jan 7, 2021

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

JohnTitor added a commit to JohnTitor/glacier that referenced this issue Jan 15, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 15, 2021
@tmiasko
Copy link
Contributor

tmiasko commented Jan 18, 2021

Minimized:

fn main() { [(&[0u8], None::<String>); 2]; }

Related to changes from #65858, which to produce a suggestion for const_in_array_repeat_expression feature, re-run const qualifs on MIR body after promotion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

6 participants