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: assert_eq!(alloc.mutability, mutability) failed in validity.rs #126537

Closed
lxl66566 opened this issue Jun 16, 2024 · 4 comments
Closed

ICE: assert_eq!(alloc.mutability, mutability) failed in validity.rs #126537

lxl66566 opened this issue Jun 16, 2024 · 4 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

@lxl66566
Copy link

Code

use std::sync::LazyLock;
static TEST = LazyLock::new(|| {});

playground

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (3cf924b93 2024-06-15)
binary: rustc
commit-hash: 3cf924b934322fd7b514600a7dc84fc517515346
commit-date: 2024-06-15
host: x86_64-pc-windows-msvc
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

thread 'rustc' panicked at compiler\rustc_const_eval\src\interpret\validity.rs:742:21:
assertion `left == right` failed
  left: Mut
 right: Not
stack backtrace:
   0:     0x7ffebf46d5d3 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffebf46d5d3 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffebf46d5d3 - std::backtrace::Backtrace::create
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\backtrace.rs:331
   3:     0x7ffebf46d51a - std::backtrace::Backtrace::force_capture
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\backtrace.rs:312
   4:     0x7ffeba59e480 - memchr
   5:     0x7ffebf487327 - alloc::boxed::impl$50::call
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\alloc\src\boxed.rs:2076
   6:     0x7ffebf487327 - std::panicking::rust_panic_with_hook
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\panicking.rs:801
   7:     0x7ffebf487136 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\panicking.rs:667
   8:     0x7ffebf48459f - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\sys_common\backtrace.rs:171
   9:     0x7ffebf486d56 - std::panicking::begin_panic_handler
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\panicking.rs:658
  10:     0x7ffebf4dd044 - core::panicking::panic_fmt
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\core\src\panicking.rs:74
  11:     0x7ffebf4dd4b1 - core::panicking::assert_failed_inner
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\core\src\panicking.rs:410
  12:     0x7ffebb14f967 - <unicode_script[324750e72d933dcb]::ScriptIterator as core[fc643a466b3abdda]::iter::traits::iterator::Iterator>::next
  13:     0x7ffeb9d0051f - <rustc_const_eval[d54cf2fd7d97ca64]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  14:     0x7ffeb9d00b66 - <rustc_const_eval[d54cf2fd7d97ca64]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  15:     0x7ffeb9d00a3b - <rustc_const_eval[d54cf2fd7d97ca64]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  16:     0x7ffeb9d00a3b - <rustc_const_eval[d54cf2fd7d97ca64]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  17:     0x7ffeb9d00a3b - <rustc_const_eval[d54cf2fd7d97ca64]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  18:     0x7ffeb9d00a3b - <rustc_const_eval[d54cf2fd7d97ca64]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  19:     0x7ffeb8d8f78f - rustc_const_eval[d54cf2fd7d97ca64]::interpret::eval_context::mir_assign_valid_types
  20:     0x7ffeb9d4bc9e - <rustc_const_eval[d54cf2fd7d97ca64]::check_consts::check::Checker as rustc_middle[b6a25c8654784a65]::mir::visit::Visitor>::visit_terminator
  21:     0x7ffeb8d9289e - rustc_const_eval[d54cf2fd7d97ca64]::const_eval::eval_queries::eval_static_initializer_provider
  22:     0x7ffeb8ce7cb8 - <dyn std[4e132f79a104a835]::io::Write as nu_ansi_term[624fbab7f32de4c3]::write::AnyWrite>::write_str
  23:     0x7ffeb8cceecd - <dyn std[4e132f79a104a835]::io::Write as nu_ansi_term[624fbab7f32de4c3]::write::AnyWrite>::write_str
  24:     0x7ffeb9a62f75 - rustc_ty_utils[65cd0fcfc91e73d9]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  25:     0x7ffeb8cf9dfc - rustc_query_impl[a5c729527a3bbe8e]::query_system
  26:     0x7ffeb9346ebe - <rustc_hir_typeck[f92100b2a9924dec]::upvar::InferBorrowKind as rustc_hir_typeck[f92100b2a9924dec]::expr_use_visitor::Delegate>::borrow
  27:     0x7ffeb93bd82c - rustc_hir_analysis[76494e9f849cc63e]::check_crate
  28:     0x7ffeb9110d82 - rustc_interface[64936c4a606e4803]::passes::resolver_for_lowering_raw
  29:     0x7ffeb6338407 - rustc_interface[64936c4a606e4803]::passes::analysis
  30:     0x7ffeb8ce898a - <dyn std[4e132f79a104a835]::io::Write as nu_ansi_term[624fbab7f32de4c3]::write::AnyWrite>::write_str
  31:     0x7ffeb8c08f39 - rustc_ty_utils[65cd0fcfc91e73d9]::ty::adt_sized_constraint
  32:     0x7ffeb8cedf13 - rustc_query_impl[a5c729527a3bbe8e]::query_system
  33:     0x7ffeb62f50cd - __ImageBase
  34:     0x7ffeb62f232f - __ImageBase
  35:     0x7ffeb62fa189 - __ImageBase
  36:     0x7ffebf49833d - alloc::boxed::impl$48::call_once
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\alloc\src\boxed.rs:2062
  37:     0x7ffebf49833d - alloc::boxed::impl$48::call_once
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\alloc\src\boxed.rs:2062
  38:     0x7ffebf49833d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\sys\pal\windows\thread.rs:52
  39:     0x7fff4668257d - BaseThreadInitThunk
  40:     0x7fff47d4aa48 - RtlUserThreadStart


rustc version: 1.81.0-nightly (3cf924b93 2024-06-15)
platform: x86_64-pc-windows-msvc

query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `git_command::TEST`
#1 [analysis] running analysis passes on this crate
end of query stack

Backtrace

error: missing type for `static` item
 --> src\git_command.rs:3:12
  |
3 | static TEST = LazyLock::new(|| {});
  |            ^
  |
note: however, the inferred type `LazyLock<(), {closure@git_command.rs:3:29}>` cannot be named
 --> src\git_command.rs:3:15
  |
3 | static TEST = LazyLock::new(|| {});
  |               ^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at compiler\rustc_const_eval\src\interpret\validity.rs:742:21:
assertion `left == right` failed
  left: Mut
 right: Not
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\panicking.rs:658
   1: core::panicking::panic_fmt
             at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\core\src\panicking.rs:74
   2: core::panicking::assert_failed_inner
             at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\core\src\panicking.rs:410
   3: <unicode_script::ScriptIterator as core::iter::traits::iterator::Iterator>::next
   4: <rustc_const_eval::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
   5: <rustc_const_eval::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
   6: <rustc_const_eval::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
   7: <rustc_const_eval::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
   8: <rustc_const_eval::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
   9: <rustc_const_eval::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  10: rustc_const_eval::interpret::eval_context::mir_assign_valid_types
  11: <rustc_const_eval::check_consts::check::Checker as rustc_middle::mir::visit::Visitor>::visit_terminator
  12: rustc_const_eval::const_eval::eval_queries::eval_static_initializer_provider
  13: <dyn std::io::Write as nu_ansi_term::write::AnyWrite>::write_str
  14: <dyn std::io::Write as nu_ansi_term::write::AnyWrite>::write_str
  15: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  16: rustc_query_impl::query_system
  17: <rustc_hir_typeck::upvar::InferBorrowKind as rustc_hir_typeck::expr_use_visitor::Delegate>::borrow
  18: rustc_hir_analysis::check_crate
  19: rustc_interface::passes::resolver_for_lowering_raw
  20: rustc_interface::passes::analysis
  21: <dyn std::io::Write as nu_ansi_term::write::AnyWrite>::write_str
  22: rustc_ty_utils::ty::adt_sized_constraint
  23: rustc_query_impl::query_system
  24: __ImageBase
  25: __ImageBase
  26: __ImageBase
  27: alloc::boxed::impl$48::call_once
             at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\alloc\src\boxed.rs:2062
  28: alloc::boxed::impl$48::call_once
             at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\alloc\src\boxed.rs:2062
  29: std::sys::pal::windows::thread::impl$0::new::thread_start
             at /rustc/3cf924b934322fd7b514600a7dc84fc517515346/library\std\src\sys\pal\windows\thread.rs:52
  30: BaseThreadInitThunk
  31: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 `D:\program\Rust\git-sync-backup\rustc-ice-2024-06-16T04_58_21-2320.txt` to your bug report

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

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

query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `git_command::TEST`
#1 [analysis] running analysis passes on this crate
end of query stack
warning: `git-sync-backup` (bin "git-sync-backup") generated 1 warning
error: could not compile `git-sync-backup` (bin "git-sync-backup") due to 1 previous error; 1 warning emitted

@lxl66566 lxl66566 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 Jun 16, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 16, 2024
@theemathas
Copy link
Contributor

This ICEs on stable, beta, and nightly

use std::sync::Once;

static TEST = Once::new();

@theemathas
Copy link
Contributor

The ICE seems to happen when a static is missing its type, and the type of the initializer has at least one byte of interior mutability.

use std::cell::UnsafeCell;

static TEST = UnsafeCell::new(1_u8);

@theemathas
Copy link
Contributor

Duplicate of #124164

@workingjubilee
Copy link
Member

Closing as duplicate.

@workingjubilee workingjubilee closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 16, 2024
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

5 participants