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: thread 'rustc' panicked at 'DefId::expect_local: DefId(2:2686 ~ core[97e0]::ptr::read) isn't local' #96874

Closed
ghost opened this issue May 9, 2022 · 2 comments
Labels
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.

Comments

@ghost
Copy link

ghost commented May 9, 2022

Code

bad code (resulting in an ICE):

std::ptr::read.local_variable

good code:

std::ptr::read(local_variable)

Meta

rustc --version --verbose:

rustc 1.62.0-nightly (cb1219871 2022-05-08)
binary: rustc
commit-hash: cb121987158d69bb894ba1bcc21dc45d1e0a488f
commit-date: 2022-05-08
host: x86_64-pc-windows-msvc
release: 1.62.0-nightly
LLVM version: 14.0.1

Error output

error: could not compile `project`; 1 warning emitted
Backtrace

thread 'rustc' panicked at 'DefId::expect_local: `DefId(2:2686 ~ core[97e0]::ptr::read)` isn't local', compiler\rustc_typeck\src\check\expr.rs:2037:31
stack backtrace:
   0:     0x7ffa5802982f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e814cf41b20d117
   1:     0x7ffa580648ea - core::fmt::write::h6ef8ff46f65f4217
   2:     0x7ffa5801be99 - <std::io::IoSlice as core::fmt::Debug>::fmt::hbe5f4eddad8f5b75
   3:     0x7ffa5802d01b - std::panicking::default_hook::h396c929ab7751517
   4:     0x7ffa5802cc0e - std::panicking::default_hook::h396c929ab7751517
   5:     0x7ffa4d2ae919 - <rustc_middle[29623e066fe8eda9]::ty::SymbolName as core[d2b554fbdd0405a5]::fmt::Debug>::fmt
   6:     0x7ffa5802d8fa - std::panicking::rust_panic_with_hook::h8f0665e3b889a766
   7:     0x7ffa5802d64d - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h3ccbe5c214919003
   8:     0x7ffa5802a327 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e814cf41b20d117
   9:     0x7ffa5802d329 - rust_begin_unwind
  10:     0x7ffa58098435 - core::panicking::panic_fmt::haba17c9659b63b1f
  11:     0x7ffa4fbeb028 - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_for_cast
  12:     0x7ffa4fc40d93 - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  13:     0x7ffa4fbdff50 - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_for_cast
  14:     0x7ffa4fc4018a - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  15:     0x7ffa4fbdff50 - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_for_cast
  16:     0x7ffa4fbfdc3d - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_decl_initializer
  17:     0x7ffa4fbfde53 - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_decl_initializer
  18:     0x7ffa4fbfe0d8 - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_stmt
  19:     0x7ffa4fbfea6c - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_block_no_value
  20:     0x7ffa4fc40d64 - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  21:     0x7ffa4fbdff50 - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_for_cast
  22:     0x7ffa4fbe0ccb - <rustc_typeck[bb8c6fbb893722e1]::check::fn_ctxt::FnCtxt>::check_for_cast
  23:     0x7ffa4fc7e2ac - <rustc_typeck[bb8c6fbb893722e1]::check::cast::CastCheck>::check
  24:     0x7ffa4fce5812 - <rustc_typeck[bb8c6fbb893722e1]::errors::ExplicitGenericArgsWithImplTraitFeature as rustc_errors[b7592d213147500e]::diagnostic::AddSubdiagnostic>::add_to_diagnostic
  25:     0x7ffa4fc993d2 - rustc_typeck[bb8c6fbb893722e1]::check::provide
  26:     0x7ffa50875998 - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  27:     0x7ffa50b13132 - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  28:     0x7ffa50997480 - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  29:     0x7ffa50ad2158 - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  30:     0x7ffa4fb51824 - <rustc_typeck[bb8c6fbb893722e1]::check::upvar::InferBorrowKind as rustc_typeck[bb8c6fbb893722e1]::expr_use_visitor::Delegate>::mutate
  31:     0x7ffa4fc9fc73 - <rustc_typeck[bb8c6fbb893722e1]::check::MaybeInProgressTables>::borrow_mut
  32:     0x7ffa50877a2e - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  33:     0x7ffa50b3b49f - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  34:     0x7ffa50a2dd6d - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  35:     0x7ffa50aa2889 - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  36:     0x7ffa4fb7d96f - <rustc_typeck[bb8c6fbb893722e1]::bounds::Bounds as core[d2b554fbdd0405a5]::fmt::Debug>::fmt
  37:     0x7ffa4fb4c5e4 - rustc_typeck[bb8c6fbb893722e1]::check_crate
  38:     0x7ffa4d3cf9bf - rustc_interface[6af4240d672c24c7]::passes::analysis
  39:     0x7ffa5087779e - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  40:     0x7ffa50b332cf - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  41:     0x7ffa50a195b4 - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  42:     0x7ffa50ad2566 - <&[(rustc_middle[29623e066fe8eda9]::ty::Predicate, rustc_span[990d3c3be2152167]::span_encoding::Span)] as rustc_serialize[9024030a5cfa6b5c]::serialize::Decodable<rustc_query_impl[f9c022100feba73d]::on_disk_cache::CacheDecoder>>::decode
  43:     0x7ffa4d2698df - <rustc_driver[e717ea9c8a6b7480]::args::Error as core[d2b554fbdd0405a5]::fmt::Debug>::fmt
  44:     0x7ffa4d23dfd9 - <rustc_lint[f77121ccb2281fd3]::BuiltinCombinedEarlyLintPass as rustc_lint[f77121ccb2281fd3]::passes::EarlyLintPass>::check_where_predicate
  45:     0x7ffa4d2c1a55 - rustc_driver[e717ea9c8a6b7480]::pretty::print_after_hir_lowering
  46:     0x7ffa4d240810 - <rustc_lint[f77121ccb2281fd3]::BuiltinCombinedEarlyLintPass as rustc_lint[f77121ccb2281fd3]::passes::EarlyLintPass>::check_where_predicate
  47:     0x7ffa4d262a87 - <rustc_lint[f77121ccb2281fd3]::BuiltinCombinedEarlyLintPass as rustc_lint[f77121ccb2281fd3]::passes::EarlyLintPass>::check_where_predicate
  48:     0x7ffa4d26c6d6 - <rustc_driver[e717ea9c8a6b7480]::args::Error as core[d2b554fbdd0405a5]::fmt::Debug>::fmt
  49:     0x7ffa4d26d7f8 - <rustc_driver[e717ea9c8a6b7480]::args::Error as core[d2b554fbdd0405a5]::fmt::Debug>::fmt
  50:     0x7ffa5803ed6c - std::sys::windows::thread::Thread::new::h7a9e3b0a36b428ff
  51:     0x7ffab47f7034 - BaseThreadInitThunk
  52:     0x7ffab5422651 - RtlUserThreadStart

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.62.0-nightly (cb1219871 2022-05-08) running on x86_64-pc-windows-msvc


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

query stack during panic:
#0 [typeck] type-checking `core::interfaces::capture::get_register_list`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

@ghost ghost 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 9, 2022
@SNCPlay42
Copy link
Contributor

Duplicate of #96583 (which isn't actually fixed until #96844 lands)

@ghost ghost changed the title ICE: core::ptr::read ICE: thread 'rustc' panicked at 'DefId::expect_local: DefId(2:2686 ~ core[97e0]::ptr::read) isn't local' May 9, 2022
@Alexendoo
Copy link
Member

Fixed by #96844

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. 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

No branches or pull requests

2 participants