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

ICE: polonius: None in region infer with unconditional panic #135646

Open
matthiaskrgr opened this issue Jan 17, 2025 · 3 comments
Open

ICE: polonius: None in region infer with unconditional panic #135646

matthiaskrgr opened this issue Jan 17, 2025 · 3 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ NLL-polonius Issues related for using Polonius in the borrow checker T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

not sure why this only panics in edition 2024 🤔

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024 -Zpolonius=next
fn main() {
    &{ [1, 2, 3][4] };
}

original:

//@ build-pass
//@ ignore-pass (test emits codegen-time warnings and verifies that they are not errors)

#![warn(unconditional_panic)]

fn main() {
    &{ [1, 2, 3][4] };
    //~^ WARN operation will panic
}

Version information

rustc 1.86.0-nightly (bcd0683e5 2025-01-17)
binary: rustc
commit-hash: bcd0683e5dce1945b5d940714742e7502883bb5c
commit-date: 2025-01-17
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Possibly related line of code:

// larger than that.
self.find_constraint_paths_between_regions(fr1, |r| {
self.cannot_name_placeholder(r, fr1)
})
})
.map(|(_path, r)| r)
.unwrap()
}
/// Get the region outlived by `longer_fr` and live at `element`.
pub(crate) fn region_from_element(
&self,
longer_fr: RegionVid,

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024 -Zpolonius=next

Program output


thread 'rustc' panicked at compiler/rustc_borrowck/src/region_infer/mod.rs:1888:10:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7077524fb0ca - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h245d3d13c9e117ef
   1:     0x707752c12d26 - core::fmt::write::ha5c79450f6a60aba
   2:     0x707753b95891 - std::io::Write::write_fmt::hc0bb623be5e87022
   3:     0x7077524faf22 - std::sys::backtrace::BacktraceLock::print::h5f0375c539e6bbfe
   4:     0x7077524fd3a2 - std::panicking::default_hook::{{closure}}::hfaae0dc7005f1f46
   5:     0x7077524fd22a - std::panicking::default_hook::had3887552141764d
   6:     0x70775165e33b - std[970739192a5a8910]::panicking::update_hook::<alloc[c190f769f0908da9]::boxed::Box<rustc_driver_impl[98a1c83b91f31d14]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7077524fdee3 - std::panicking::rust_panic_with_hook::h0f6e30840497503a
   8:     0x7077524fdba6 - std::panicking::begin_panic_handler::{{closure}}::h00d1f33c4abe282b
   9:     0x7077524fb5a9 - std::sys::backtrace::__rust_end_short_backtrace::h7f80f131d37aefa4
  10:     0x7077524fd89d - rust_begin_unwind
  11:     0x70774f1a8530 - core::panicking::panic_fmt::h313dbd2ed26f8657
  12:     0x70774fcc082c - core::panicking::panic::h6bed83e7eae20130
  13:     0x70775067d5a9 - core::option::unwrap_failed::h5e1ae1d3b98bd9cb
  14:     0x70775143be47 - <rustc_borrowck[4bd42f5d1352065e]::region_infer::RegionInferenceContext>::find_sub_region_live_at
  15:     0x707750fd0fb4 - <rustc_borrowck[4bd42f5d1352065e]::MirBorrowckCtxt>::explain_why_borrow_contains_point
  16:     0x707750e18b6b - <rustc_borrowck[4bd42f5d1352065e]::MirBorrowckCtxt>::report_borrowed_value_does_not_live_long_enough
  17:     0x707753cf134f - rustc_borrowck[4bd42f5d1352065e]::do_mir_borrowck
  18:     0x707753cc352f - rustc_query_impl[a1940b4b03f25947]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a1940b4b03f25947]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a423a87a2792eea]::query::erase::Erased<[u8; 8usize]>>
  19:     0x707752f2260e - rustc_query_system[f87afe778d5ed02f]::query::plumbing::try_execute_query::<rustc_query_impl[a1940b4b03f25947]::DynamicConfig<rustc_data_structures[7c7a3305c98b4df4]::vec_cache::VecCache<rustc_span[e90766ed4fb19497]::def_id::LocalDefId, rustc_middle[1a423a87a2792eea]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[f87afe778d5ed02f]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a1940b4b03f25947]::plumbing::QueryCtxt, false>
  20:     0x707752f22113 - rustc_query_impl[a1940b4b03f25947]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  21:     0x707752f16fb0 - rustc_interface[f2cc204a1e18dc42]::passes::run_required_analyses
  22:     0x707753b9109e - rustc_interface[f2cc204a1e18dc42]::passes::analysis
  23:     0x707753b9106f - rustc_query_impl[a1940b4b03f25947]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a1940b4b03f25947]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a423a87a2792eea]::query::erase::Erased<[u8; 0usize]>>
  24:     0x707753be8355 - rustc_query_system[f87afe778d5ed02f]::query::plumbing::try_execute_query::<rustc_query_impl[a1940b4b03f25947]::DynamicConfig<rustc_query_system[f87afe778d5ed02f]::query::caches::SingleCache<rustc_middle[1a423a87a2792eea]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[a1940b4b03f25947]::plumbing::QueryCtxt, false>
  25:     0x707753be808e - rustc_query_impl[a1940b4b03f25947]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  26:     0x707753c5c2e9 - rustc_interface[f2cc204a1e18dc42]::passes::create_and_enter_global_ctxt::<core[31d5326fba56f7df]::option::Option<rustc_interface[f2cc204a1e18dc42]::queries::Linker>, rustc_driver_impl[98a1c83b91f31d14]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  27:     0x707753c4f4d6 - rustc_interface[f2cc204a1e18dc42]::interface::run_compiler::<(), rustc_driver_impl[98a1c83b91f31d14]::run_compiler::{closure#0}>::{closure#1}
  28:     0x707753a92c07 - std[970739192a5a8910]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f2cc204a1e18dc42]::util::run_in_thread_with_globals<rustc_interface[f2cc204a1e18dc42]::util::run_in_thread_pool_with_globals<rustc_interface[f2cc204a1e18dc42]::interface::run_compiler<(), rustc_driver_impl[98a1c83b91f31d14]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  29:     0x707753a928d9 - <<std[970739192a5a8910]::thread::Builder>::spawn_unchecked_<rustc_interface[f2cc204a1e18dc42]::util::run_in_thread_with_globals<rustc_interface[f2cc204a1e18dc42]::util::run_in_thread_pool_with_globals<rustc_interface[f2cc204a1e18dc42]::interface::run_compiler<(), rustc_driver_impl[98a1c83b91f31d14]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[31d5326fba56f7df]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x707753a9206b - std::sys::pal::unix::thread::Thread::new::thread_start::h84cef28dceb72f89
  31:     0x70774dea339d - <unknown>
  32:     0x70774df2849c - <unknown>
  33:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.86.0-nightly (bcd0683e5 2025-01-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z polonius=next -Z dump-mir-dir=dir

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

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ NLL-polonius Issues related for using Polonius in the borrow checker T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 17, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 17, 2025
@matthiaskrgr
Copy link
Member Author

#134980 cc @lqd obviously ^^

@lqd
Copy link
Member

lqd commented Jan 17, 2025

Ah thanks, but I'm aware of this diagnostics ICE: not all tests pass with -Zpolonius=next yet in the first place (and this ICE is one of the differences in diagnostics).

The implementation is still a work-in-progress. There's no need to fuzz it yet (I think we may have discussed this before, I remember another fuzzer also asking about this on zulip).

I'll still assign it to me.

@lqd lqd self-assigned this Jan 17, 2025
@lqd lqd added A-diagnostics Area: Messages for errors, warnings, and lints T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 17, 2025
@matthiaskrgr
Copy link
Member Author

So far I have only run this on the vanilla rustc tests and this ice (assuming all other occurrences had the same root cause) was the only one that showed up 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ NLL-polonius Issues related for using Polonius in the borrow checker T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants