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 on min_exhaustive_patterns pointer dereference #129009

Closed
ShoyuVanilla opened this issue Aug 12, 2024 · 2 comments · Fixed by #129062
Closed

ICE on min_exhaustive_patterns pointer dereference #129009

ShoyuVanilla opened this issue Aug 12, 2024 · 2 comments · Fixed by #129062
Assignees
Labels
C-bug Category: This is a bug. F-min_exhaustive_patterns `#![feature(min_exhaustive_patterns)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ShoyuVanilla
Copy link
Member

Rust Playground with 1.82.0-nightly(2024-08-11 41dd149)

#![feature(never_type)]

fn main() {}

fn panique(ptr: *const Result<i32, !>) {
    unsafe {
        let Ok(_x) = *ptr;
    }
}

yeets

Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at compiler/rustc_mir_build/src/thir/pattern/check_match.rs:707:13:
assertion failed: inhabited.apply(self.tcx, cx.param_env, cx.module)
stack backtrace:
   0:     0x7ff4a76afead - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h17d06336c5e3b1ba
   1:     0x7ff4a7edd7ef - core::fmt::write::ha36b31577d300920
   2:     0x7ff4a8e5f451 - std::io::Write::write_fmt::h87580c3a702d3643
   3:     0x7ff4a76b257b - std::panicking::default_hook::{{closure}}::hf5abd452e6300672
   4:     0x7ff4a76b21ee - std::panicking::default_hook::h17d581bf85c3535e
   5:     0x7ff4a682d618 - std[f5c760e4f6201609]::panicking::update_hook::<alloc[fc5d5d75bd142d1a]::boxed::Box<rustc_driver_impl[5153b23ca80fb7ed]::install_ice_hook::{closure#0}>>::{closure#0}
   6:     0x7ff4a76b2e97 - std::panicking::rust_panic_with_hook::h7c1411cde88a7f7f
   7:     0x7ff4a76b2b23 - std::panicking::begin_panic_handler::{{closure}}::ha913deac649d6768
   8:     0x7ff4a76b0369 - std::sys::backtrace::__rust_end_short_backtrace::hf5c0fd0c12c83077
   9:     0x7ff4a76b2824 - rust_begin_unwind
  10:     0x7ff4a485ea03 - core::panicking::panic_fmt::h0ffd474c249f012b
  11:     0x7ff4a476844c - core::panicking::panic::h663a3891a256607c
  12:     0x7ff4a8721596 - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor>::check_binding_is_irrefutable
  13:     0x7ff4a4f99cc4 - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor as rustc_middle[82a8b21925effaa0]::thir::visit::Visitor>::visit_expr
  14:     0x7ff4a4f98e4d - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor as rustc_middle[82a8b21925effaa0]::thir::visit::Visitor>::visit_expr
  15:     0x7ff4a4f99a5c - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor as rustc_middle[82a8b21925effaa0]::thir::visit::Visitor>::visit_expr
  16:     0x7ff4a4f98e4d - <rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::MatchVisitor as rustc_middle[82a8b21925effaa0]::thir::visit::Visitor>::visit_expr
  17:     0x7ff4a871e197 - rustc_mir_build[3fa758602a6f6eb0]::thir::pattern::check_match::check_match
  18:     0x7ff4a871ddb3 - rustc_query_impl[3b91f71dedc7f6af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b91f71dedc7f6af]::query_impl::check_match::dynamic_query::{closure#2}::{closure#0}, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 1usize]>>
  19:     0x7ff4a871d5e6 - rustc_query_system[10e08ee6835a9bbf]::query::plumbing::try_execute_query::<rustc_query_impl[3b91f71dedc7f6af]::DynamicConfig<rustc_query_system[10e08ee6835a9bbf]::query::caches::VecCache<rustc_span[70e7603d74aa2ff6]::def_id::LocalDefId, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3b91f71dedc7f6af]::plumbing::QueryCtxt, false>
  20:     0x7ff4a871d25d - rustc_query_impl[3b91f71dedc7f6af]::query_impl::check_match::get_query_non_incr::__rust_end_short_backtrace
  21:     0x7ff4a872a74e - rustc_mir_build[3fa758602a6f6eb0]::build::mir_build
  22:     0x7ff4a8729e12 - rustc_query_impl[3b91f71dedc7f6af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b91f71dedc7f6af]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 8usize]>>
  23:     0x7ff4a824ecf9 - rustc_query_system[10e08ee6835a9bbf]::query::plumbing::try_execute_query::<rustc_query_impl[3b91f71dedc7f6af]::DynamicConfig<rustc_query_system[10e08ee6835a9bbf]::query::caches::VecCache<rustc_span[70e7603d74aa2ff6]::def_id::LocalDefId, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[3b91f71dedc7f6af]::plumbing::QueryCtxt, false>
  24:     0x7ff4a824e80d - rustc_query_impl[3b91f71dedc7f6af]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7ff4a4599093 - rustc_mir_build[3fa758602a6f6eb0]::check_unsafety::check_unsafety
  26:     0x7ff4a8288f0b - rustc_query_impl[3b91f71dedc7f6af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b91f71dedc7f6af]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7ff4a82886ff - rustc_query_system[10e08ee6835a9bbf]::query::plumbing::try_execute_query::<rustc_query_impl[3b91f71dedc7f6af]::DynamicConfig<rustc_query_system[10e08ee6835a9bbf]::query::caches::VecCache<rustc_span[70e7603d74aa2ff6]::def_id::LocalDefId, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[3b91f71dedc7f6af]::plumbing::QueryCtxt, false>
  28:     0x7ff4a82883c1 - rustc_query_impl[3b91f71dedc7f6af]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7ff4a824400c - rustc_interface[adec5331f4e06f9b]::passes::run_required_analyses
  30:     0x7ff4a8bfff9e - rustc_interface[adec5331f4e06f9b]::passes::analysis
  31:     0x7ff4a8bfff71 - rustc_query_impl[3b91f71dedc7f6af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b91f71dedc7f6af]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7ff4a8e6286e - rustc_query_system[10e08ee6835a9bbf]::query::plumbing::try_execute_query::<rustc_query_impl[3b91f71dedc7f6af]::DynamicConfig<rustc_query_system[10e08ee6835a9bbf]::query::caches::SingleCache<rustc_middle[82a8b21925effaa0]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3b91f71dedc7f6af]::plumbing::QueryCtxt, false>
  33:     0x7ff4a8e625cf - rustc_query_impl[3b91f71dedc7f6af]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7ff4a8d05dab - rustc_interface[adec5331f4e06f9b]::interface::run_compiler::<core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>, rustc_driver_impl[5153b23ca80fb7ed]::run_compiler::{closure#0}>::{closure#1}
  35:     0x7ff4a90bee44 - std[f5c760e4f6201609]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[adec5331f4e06f9b]::util::run_in_thread_with_globals<rustc_interface[adec5331f4e06f9b]::util::run_in_thread_pool_with_globals<rustc_interface[adec5331f4e06f9b]::interface::run_compiler<core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>, rustc_driver_impl[5153b23ca80fb7ed]::run_compiler::{closure#0}>::{closure#1}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#0}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>
  36:     0x7ff4a8d8f8f4 - <<std[f5c760e4f6201609]::thread::Builder>::spawn_unchecked_<rustc_interface[adec5331f4e06f9b]::util::run_in_thread_with_globals<rustc_interface[adec5331f4e06f9b]::util::run_in_thread_pool_with_globals<rustc_interface[adec5331f4e06f9b]::interface::run_compiler<core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>, rustc_driver_impl[5153b23ca80fb7ed]::run_compiler::{closure#0}>::{closure#1}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#0}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c9e7e1236848907c]::result::Result<(), rustc_span[70e7603d74aa2ff6]::ErrorGuaranteed>>::{closure#1} as core[c9e7e1236848907c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7ff4a8d8fdeb - std::sys::pal::unix::thread::Thread::new::thread_start::hd745a5b068b8240f
  38:     0x7ff4a32a9609 - start_thread
  39:     0x7ff4a31ce353 - clone
  40:                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: please attach the file at `/playground/rustc-ice-2024-08-12T15_12_57-23.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [check_match] match-checking `panique`
#1 [mir_built] building MIR for `panique`
end of query stack
error: could not compile `playground` (bin "playground")
@ShoyuVanilla ShoyuVanilla added the C-bug Category: This is a bug. label Aug 12, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 12, 2024
@ShoyuVanilla ShoyuVanilla changed the title ICE on min_exhaustive_patterns point dereference ICE on min_exhaustive_patterns pointer dereference Aug 12, 2024
@compiler-errors
Copy link
Member

cc @Nadrieril

@jieyouxu jieyouxu added 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. F-never_type `#![feature(never_type)]` S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue F-min_exhaustive_patterns `#![feature(min_exhaustive_patterns)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 13, 2024
@WaffleLapkin
Copy link
Member

you don't need never type, this works (ICEs) with any uninhabited type (play)

fn main() {}

fn panique(ptr: *const Result<i32, std::convert:: Infallible>) {
    unsafe {
        let Ok(_x) = *ptr;
    }
}

@WaffleLapkin WaffleLapkin removed the F-never_type `#![feature(never_type)]` label Aug 13, 2024
@Nadrieril Nadrieril self-assigned this Aug 13, 2024
@bors bors closed this as completed in e01d614 Aug 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 14, 2024
Rollup merge of rust-lang#129062 - Nadrieril:fix-129009, r=compiler-errors

Remove a no-longer-true assert

Fixes rust-lang#129009

The assert was simply no longer true. I thought my test suite was thorough but I had not noticed these `let`-specific diagnostics codepaths.

r? `@compiler-errors`
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. F-min_exhaustive_patterns `#![feature(min_exhaustive_patterns)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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