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

Nightly ICE: Using function pointer as reg argument in asm! macro causes rustc panic #97490

Closed
VisualEhrmanntraut opened this issue May 28, 2022 · 0 comments · Fixed by #97493
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@VisualEhrmanntraut
Copy link

Encountered while compiling my UEFI boot-loader project.

Issue reproduction code

pub type Yes = extern "sysv64" fn(&'static u8) -> !;

fn main() {
    unsafe {
        let yes = &6 as *const _ as *const Yes;
        core::arch::asm!("call {}", in(reg) yes, options(noreturn));
    }
}

Meta

rustc --version --verbose:

rustc 1.63.0-nightly (ebbcbfc23 2022-05-27)
binary: rustc
commit-hash: ebbcbfc236ced21d5e6a92269edb704692ff26b8
commit-date: 2022-05-27
host: x86_64-apple-darwin
release: 1.63.0-nightly
LLVM version: 14.0.4

Error output

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 120', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10
Backtrace

stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <ena::unify::UnificationTable<ena::unify::backing_vec::InPlace<rustc_middle::infer::unify_key::RegionVidKey, &mut alloc::vec::Vec<ena::unify::VarValue<rustc_middle::infer::unify_key::RegionVidKey>>, &mut rustc_infer::infer::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key
   4: <rustc_infer::infer::canonical::canonicalizer::Canonicalizer as rustc_middle::ty::fold::TypeFolder>::fold_region
   5: <rustc_middle::ty::Ty as rustc_middle::ty::fold::TypeFoldable>::super_fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>
   6: <&rustc_middle::ty::list::List<rustc_middle::ty::Ty> as rustc_middle::ty::fold::TypeFoldable>::try_fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>
   7: <rustc_middle::ty::Ty as rustc_middle::ty::fold::TypeFoldable>::super_fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>
   8: <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_middle::ty::fold::TypeFoldable>::try_fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>
   9: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::try_fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>
  10: <rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate> as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>
  11: <rustc_infer::infer::canonical::canonicalizer::Canonicalizer>::canonicalize::<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate>>
  12: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  13: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  14: rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions
  15: <rustc_infer::infer::InferCtxtBuilder>::enter::<bool, rustc_ty_utils::common_traits::is_item_raw::{closure#0}>
  16: rustc_ty_utils::common_traits::is_item_raw
  17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, bool>>
  18: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::is_copy_raw, rustc_query_impl::plumbing::QueryCtxt>
  19: <rustc_middle::ty::Ty>::is_copy_modulo_regions
  20: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_asm_operand_type
  21: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_asm
  22: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_asms
  23: <rustc_infer::infer::InferCtxtBuilder>::enter::<&rustc_middle::ty::context::TypeckResults, <rustc_typeck::check::inherited::InheritedBuilder>::enter<rustc_typeck::check::typeck_with_fallback<rustc_typeck::check::typeck::{closure#0}>::{closure#1}, &rustc_middle::ty::context::TypeckResults>::{closure#0}>
  24: rustc_typeck::check::typeck
  25: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>>
  26: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
  27: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_typeck::check::typeck_item_bodies::{closure#0}>
  28: rustc_typeck::check::typeck_item_bodies
  29: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), ()>>
  30: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
  31: <rustc_session::session::Session>::time::<(), rustc_typeck::check_crate::{closure#7}>
  32: rustc_typeck::check_crate
  33: rustc_interface::passes::analysis
  34: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  35: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  36: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  37: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  38: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  39: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  40: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
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.63.0-nightly (ebbcbfc23 2022-05-27) running on x86_64-apple-darwin

note: compiler flags: --crate-type bin -C opt-level=3 -C lto -Z unstable-options

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

query stack during panic:
#0 [is_copy_raw] computing whether `extern "sysv64" fn(&kaboom::Explosion) -> !` is `Copy`
#1 [typeck] type-checking `efi_main`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack

@VisualEhrmanntraut VisualEhrmanntraut 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 May 28, 2022
@VisualEhrmanntraut VisualEhrmanntraut changed the title ICE: Using function pointer as reg argument in asm! macro causes rustc panic Nightly ICE: Using function pointer as reg argument in asm! macro causes rustc panic May 28, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 29, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 29, 2022
Use `type_is_copy_modulo_regions` check in intrisicck

This one canoncalizes region variables correctly, preventing an ICE

Fixes rust-lang#97490
compiler-errors added a commit to compiler-errors/rust that referenced this issue May 29, 2022
Use `type_is_copy_modulo_regions` check in intrisicck

This one canoncalizes region variables correctly, preventing an ICE

Fixes rust-lang#97490
@bors bors closed this as completed in 56026e2 May 30, 2022
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) ❄️ 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.

2 participants