rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
94.9k stars 12.23k forks source link

Compiler panic in fastrand #126741

Open BobG1983 opened 2 weeks ago

BobG1983 commented 2 weeks ago

Repro:

Rustc Version: rustc 1.81.0-nightly (59e2c01c2 2024-06-17) Toolchain: nightly-x86_64-pc-windows-msvc

What I did: Clone https://www.github.com/BobG1983/rantz_random.git run cargo test run cargo test again.

Issue:

The compiler panics with the following output:

thread 'rustc' panicked at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db\compiler\rustc_data_structures\src\sync.rs:338:42:
assertion failed: *old == value
stack backtrace:
   0:     0x7ffe2a00d5d3 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffe2a00d5d3 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffe2a00d5d3 - std::backtrace::Backtrace::create
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\backtrace.rs:331
   3:     0x7ffe2a00d51a - std::backtrace::Backtrace::force_capture
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\backtrace.rs:312
   4:     0x7ffde674e510 - memchr
   5:     0x7ffe2a027337 - alloc::boxed::impl$50::call
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2076
   6:     0x7ffe2a027337 - std::panicking::rust_panic_with_hook
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:801
   7:     0x7ffe2a02710f - std::panicking::begin_panic_handler::closure$0
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:660
   8:     0x7ffe2a0245af - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\sys\backtrace.rs:171
   9:     0x7ffe2a026d66 - std::panicking::begin_panic_handler
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:658
  10:     0x7ffe2a07cf64 - core::panicking::panic_fmt
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\core\src\panicking.rs:74
  11:     0x7ffe2a07d00d - core::panicking::panic
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\core\src\panicking.rs:148
  12:     0x7ffde51a4443 - <rustc_middle[3720665636316a56]::ty::context::TyCtxt>::set_alloc_id_same_memory
  13:     0x7ffde507a807 - <rustc_metadata[beec48ef7521b97d]::rmeta::decoder::DecodeContext as rustc_type_ir[69993b1d9e925772]::codec::TyDecoder>::decode_alloc_id
  14:     0x7ffde6247d9b - <aho_corasick[ac69cc43042af094]::util::prefilter::Builder>::build
  15:     0x7ffde6232446 - <aho_corasick[ac69cc43042af094]::util::prefilter::Builder>::build
  16:     0x7ffde62cdfc3 - <rustc_metadata[beec48ef7521b97d]::creader::alloc_error_handler_spans::Finder as rustc_ast[9ac2f267a929ff38]::visit::Visitor>::visit_item
  17:     0x7ffde5d3de6b - rustc_query_impl[f350898e45c5ba56]::plumbing::query_key_hash_verify_all
  18:     0x7ffde5c3453e - rustc_ty_utils[4ce48a55c0187f78]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  19:     0x7ffde4e95ad5 - rustc_query_impl[f350898e45c5ba56]::query_system
  20:     0x7ffde661731f - <rustc_middle[3720665636316a56]::ty::context::TyCtxt>::instance_mir
  21:     0x7ffde61d8ab3 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  22:     0x7ffde61d5bc9 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  23:     0x7ffde61d7872 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  24:     0x7ffde76ebb5d - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  25:     0x7ffde76f0727 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  26:     0x7ffde76ebe18 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  27:     0x7ffde76f0727 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  28:     0x7ffde76ebe18 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  29:     0x7ffde76f0727 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  30:     0x7ffde76ebe18 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  31:     0x7ffde76f5a57 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  32:     0x7ffde7db1669 - <rayon_core[744fdfe6ee7fdbd]::registry::WorkerThread>::wait_until_cold
  33:     0x7ffde7dadc35 - <rayon_core[744fdfe6ee7fdbd]::registry::ThreadBuilder>::run
  34:     0x7ffde67514dc - memchr
  35:     0x7ffde6745efd - memchr
  36:     0x7ffde6750dd1 - memchr
  37:     0x7ffe2a03834d - alloc::boxed::impl$48::call_once
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2062
  38:     0x7ffe2a03834d - alloc::boxed::impl$48::call_once
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2062
  39:     0x7ffe2a03834d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\sys\pal\windows\thread.rs:52
  40:     0x7ffeb94c257d - BaseThreadInitThunk
  41:     0x7ffeba70af28 - RtlUserThreadStart

rustc version: 1.81.0-nightly (59e2c01c2 2024-06-17)
platform: x86_64-pc-windows-msvc

query stack during panic:
#0 [optimized_mir] optimizing MIR for `fastrand::global_rng::u128`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
thread 'rustc' panicked at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db\compiler\rustc_data_structures\src\sync.rs:338:42:
assertion failed: *old == value
stack backtrace:
   0:     0x7ffe2a00d5d3 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffe2a00d5d3 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffe2a00d5d3 - std::backtrace::Backtrace::create
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\backtrace.rs:331
   3:     0x7ffe2a00d51a - std::backtrace::Backtrace::force_capture
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\backtrace.rs:312
   4:     0x7ffde674e510 - memchr
   5:     0x7ffe2a027337 - alloc::boxed::impl$50::call
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2076
   6:     0x7ffe2a027337 - std::panicking::rust_panic_with_hook
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:801
   7:     0x7ffe2a02710f - std::panicking::begin_panic_handler::closure$0
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:660
   8:     0x7ffe2a0245af - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\sys\backtrace.rs:171
   9:     0x7ffe2a026d66 - std::panicking::begin_panic_handler
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:658
  10:     0x7ffe2a07cf64 - core::panicking::panic_fmt
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\core\src\panicking.rs:74
  11:     0x7ffe2a07d00d - core::panicking::panic
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\core\src\panicking.rs:148
  12:     0x7ffde51a4443 - <rustc_middle[3720665636316a56]::ty::context::TyCtxt>::set_alloc_id_same_memory
  13:     0x7ffde507a807 - <rustc_metadata[beec48ef7521b97d]::rmeta::decoder::DecodeContext as rustc_type_ir[69993b1d9e925772]::codec::TyDecoder>::decode_alloc_id
  14:     0x7ffde6247d9b - <aho_corasick[ac69cc43042af094]::util::prefilter::Builder>::build
  15:     0x7ffde6232446 - <aho_corasick[ac69cc43042af094]::util::prefilter::Builder>::build
  16:     0x7ffde62cdfc3 - <rustc_metadata[beec48ef7521b97d]::creader::alloc_error_handler_spans::Finder as rustc_ast[9ac2f267a929ff38]::visit::Visitor>::visit_item
  17:     0x7ffde5d3de6b - rustc_query_impl[f350898e45c5ba56]::plumbing::query_key_hash_verify_all
  18:     0x7ffde5c3453e - rustc_ty_utils[4ce48a55c0187f78]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  19:     0x7ffde4e95ad5 - rustc_query_impl[f350898e45c5ba56]::query_system
  20:     0x7ffde661731f - <rustc_middle[3720665636316a56]::ty::context::TyCtxt>::instance_mir
  21:     0x7ffde61d8ab3 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  22:     0x7ffde61d5bc9 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  23:     0x7ffde61d7872 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  24:     0x7ffde76ebb5d - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  25:     0x7ffde76f0727 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  26:     0x7ffde76ebe18 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  27:     0x7ffde76f0727 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  28:     0x7ffde76ebe18 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  29:     0x7ffde76f5a57 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  30:     0x7ffde7db1669 - <rayon_core[744fdfe6ee7fdbd]::registry::WorkerThread>::wait_until_cold
  31:     0x7ffde7dadc35 - <rayon_core[744fdfe6ee7fdbd]::registry::ThreadBuilder>::run
  32:     0x7ffde67514dc - memchr
  33:     0x7ffde6745efd - memchr
  34:     0x7ffde6750dd1 - memchr
  35:     0x7ffe2a03834d - alloc::boxed::impl$48::call_once
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2062
  36:     0x7ffe2a03834d - alloc::boxed::impl$48::call_once
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2062
  37:     0x7ffe2a03834d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\sys\pal\windows\thread.rs:52
  38:     0x7ffeb94c257d - BaseThreadInitThunk
  39:     0x7ffeba70af28 - RtlUserThreadStart

query stack during panic:
#0 [optimized_mir] optimizing MIR for `fastrand::global_rng::i64`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
thread 'rustc' panicked at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db\compiler\rustc_data_structures\src\sync.rs:338:42:
assertion failed: *old == value
stack backtrace:
   0:     0x7ffe2a00d5d3 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffe2a00d5d3 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffe2a00d5d3 - std::backtrace::Backtrace::create
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\backtrace.rs:331
   3:     0x7ffe2a00d51a - std::backtrace::Backtrace::force_capture
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\backtrace.rs:312
   4:     0x7ffde674e510 - memchr
   5:     0x7ffe2a027337 - alloc::boxed::impl$50::call
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2076
   6:     0x7ffe2a027337 - std::panicking::rust_panic_with_hook
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:801
   7:     0x7ffe2a02710f - std::panicking::begin_panic_handler::closure$0
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:660
   8:     0x7ffe2a0245af - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\sys\backtrace.rs:171
   9:     0x7ffe2a026d66 - std::panicking::begin_panic_handler
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:658
  10:     0x7ffe2a07cf64 - core::panicking::panic_fmt
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\core\src\panicking.rs:74
  11:     0x7ffe2a07d00d - core::panicking::panic
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\core\src\panicking.rs:148
  12:     0x7ffde51a4443 - <rustc_middle[3720665636316a56]::ty::context::TyCtxt>::set_alloc_id_same_memory
  13:     0x7ffde507a807 - <rustc_metadata[beec48ef7521b97d]::rmeta::decoder::DecodeContext as rustc_type_ir[69993b1d9e925772]::codec::TyDecoder>::decode_alloc_id
  14:     0x7ffde6247d9b - <aho_corasick[ac69cc43042af094]::util::prefilter::Builder>::build
  15:     0x7ffde6232446 - <aho_corasick[ac69cc43042af094]::util::prefilter::Builder>::build
  16:     0x7ffde62cdfc3 - <rustc_metadata[beec48ef7521b97d]::creader::alloc_error_handler_spans::Finder as rustc_ast[9ac2f267a929ff38]::visit::Visitor>::visit_item
  17:     0x7ffde5d3de6b - rustc_query_impl[f350898e45c5ba56]::plumbing::query_key_hash_verify_all
  18:     0x7ffde5c3453e - rustc_ty_utils[4ce48a55c0187f78]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  19:     0x7ffde4e95ad5 - rustc_query_impl[f350898e45c5ba56]::query_system
  20:     0x7ffde661731f - <rustc_middle[3720665636316a56]::ty::context::TyCtxt>::instance_mir
  21:     0x7ffde61d8ab3 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  22:     0x7ffde61d5bc9 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  23:     0x7ffde61d7872 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  24:     0x7ffde76ebb5d - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  25:     0x7ffde76f0814 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  26:     0x7ffde76ebe18 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  27:     0x7ffde76f0727 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  28:     0x7ffde76ebe18 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  29:     0x7ffde76f5a57 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  30:     0x7ffde7db1669 - <rayon_core[744fdfe6ee7fdbd]::registry::WorkerThread>::wait_until_cold
  31:     0x7ffde7dadc35 - <rayon_core[744fdfe6ee7fdbd]::registry::ThreadBuilder>::run
  32:     0x7ffde67514dc - memchr
  33:     0x7ffde6745efd - memchr
  34:     0x7ffde6750dd1 - memchr
  35:     0x7ffe2a03834d - alloc::boxed::impl$48::call_once
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2062
  36:     0x7ffe2a03834d - alloc::boxed::impl$48::call_once
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2062
  37:     0x7ffe2a03834d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\sys\pal\windows\thread.rs:52
  38:     0x7ffeb94c257d - BaseThreadInitThunk
  39:     0x7ffeba70af28 - RtlUserThreadStart

query stack during panic:
#0 [optimized_mir] optimizing MIR for `fastrand::global_rng::i8`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
thread 'rustc' panicked at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db\compiler\rustc_data_structures\src\sync.rs:338:42:
assertion failed: *old == value
stack backtrace:
   0:     0x7ffe2a00d5d3 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffe2a00d5d3 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffe2a00d5d3 - std::backtrace::Backtrace::create
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\backtrace.rs:331
   3:     0x7ffe2a00d51a - std::backtrace::Backtrace::force_capture
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\backtrace.rs:312
   4:     0x7ffde674e510 - memchr
   5:     0x7ffe2a027337 - alloc::boxed::impl$50::call
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2076
   6:     0x7ffe2a027337 - std::panicking::rust_panic_with_hook
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:801
   7:     0x7ffe2a02710f - std::panicking::begin_panic_handler::closure$0
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:660
   8:     0x7ffe2a0245af - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\sys\backtrace.rs:171
   9:     0x7ffe2a026d66 - std::panicking::begin_panic_handler
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\panicking.rs:658
  10:     0x7ffe2a07cf64 - core::panicking::panic_fmt
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\core\src\panicking.rs:74
  11:     0x7ffe2a07d00d - core::panicking::panic
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\core\src\panicking.rs:148
  12:     0x7ffde51a4443 - <rustc_middle[3720665636316a56]::ty::context::TyCtxt>::set_alloc_id_same_memory
  13:     0x7ffde507a807 - <rustc_metadata[beec48ef7521b97d]::rmeta::decoder::DecodeContext as rustc_type_ir[69993b1d9e925772]::codec::TyDecoder>::decode_alloc_id
  14:     0x7ffde6247d9b - <aho_corasick[ac69cc43042af094]::util::prefilter::Builder>::build
  15:     0x7ffde6232446 - <aho_corasick[ac69cc43042af094]::util::prefilter::Builder>::build
  16:     0x7ffde62cdfc3 - <rustc_metadata[beec48ef7521b97d]::creader::alloc_error_handler_spans::Finder as rustc_ast[9ac2f267a929ff38]::visit::Visitor>::visit_item
  17:     0x7ffde5d3de6b - rustc_query_impl[f350898e45c5ba56]::plumbing::query_key_hash_verify_all
  18:     0x7ffde5c3453e - rustc_ty_utils[4ce48a55c0187f78]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  19:     0x7ffde4e95ad5 - rustc_query_impl[f350898e45c5ba56]::query_system
  20:     0x7ffde661731f - <rustc_middle[3720665636316a56]::ty::context::TyCtxt>::instance_mir
  21:     0x7ffde61d8ab3 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  22:     0x7ffde61d5bc9 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  23:     0x7ffde61d7872 - rustc_monomorphize[cd4d3c758268f64]::is_call_from_compiler_builtins_to_upstream_monomorphization
  24:     0x7ffde76ebb5d - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  25:     0x7ffde76f0727 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  26:     0x7ffde76ebe18 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  27:     0x7ffde76f5a57 - <gimli[87f9d3ffa14e46ff]::write::str::LineStringTable>::get
  28:     0x7ffde7db1669 - <rayon_core[744fdfe6ee7fdbd]::registry::WorkerThread>::wait_until_cold
  29:     0x7ffde7dadc35 - <rayon_core[744fdfe6ee7fdbd]::registry::ThreadBuilder>::run
  30:     0x7ffde67514dc - memchr
  31:     0x7ffde6745efd - memchr
  32:     0x7ffde6750dd1 - memchr
  33:     0x7ffe2a03834d - alloc::boxed::impl$48::call_once
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2062
  34:     0x7ffe2a03834d - alloc::boxed::impl$48::call_once
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\alloc\src\boxed.rs:2062
  35:     0x7ffe2a03834d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library\std\src\sys\pal\windows\thread.rs:52
  36:     0x7ffeb94c257d - BaseThreadInitThunk
  37:     0x7ffeba70af28 - RtlUserThreadStart

query stack during panic:
#0 [optimized_mir] optimizing MIR for `fastrand::global_rng::i16`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
Nemo157 commented 1 week ago

I just got a very similar ICE while compiling a proprietary codebase

``` thread 'rustc' panicked at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/compiler/rustc_data_structures/src/sync.rs:338:42: assertion failed: *old == value stack backtrace: 0: 0x7f6fe6d44975 - std::backtrace_rs::backtrace::libunwind::trace::h184e33fa7a4efbe9 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5 1: 0x7f6fe6d44975 - std::backtrace_rs::backtrace::trace_unsynchronized::hc3eac562c05961d9 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f6fe6d44975 - std::backtrace::Backtrace::create::h85924e152703a8fb at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/backtrace.rs:331:13 3: 0x7f6fe6d448c5 - std::backtrace::Backtrace::force_capture::h3dc650b8da4f2095 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/backtrace.rs:312:9 4: 0x7f6fea0c7206 - std[c3fbaf9a0386b13c]::panicking::update_hook::>::{closure#0} 5: 0x7f6fe6d5fa4f - as core::ops::function::Fn>::call::ha3b0d962ec1ff02b at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/alloc/src/boxed.rs:2076:9 6: 0x7f6fe6d5fa4f - std::panicking::rust_panic_with_hook::h0adf1873cdd8ce86 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/panicking.rs:801:13 7: 0x7f6fe6d5f643 - std::panicking::begin_panic_handler::{{closure}}::h14e7b85ca1885ac4 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/panicking.rs:660:13 8: 0x7f6fe6d5cdf9 - std::sys::backtrace::__rust_end_short_backtrace::h17e9af05fae71c34 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/sys/backtrace.rs:171:18 9: 0x7f6fe6d5f324 - rust_begin_unwind at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/panicking.rs:658:5 10: 0x7f6fe6da9a73 - core::panicking::panic_fmt::h273dffa90a45a379 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/core/src/panicking.rs:74:14 11: 0x7f6fe6da9afc - core::panicking::panic::hf430b0f328d1e0c3 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/core/src/panicking.rs:148:5 12: 0x7f6febda652a - ::set_alloc_id_same_memory 13: 0x7f6febda817a - ::decode_alloc_id 14: 0x7f6fec689761 - >::decode.warm 15: 0x7f6feb6de740 - >::decode 16: 0x7f6febb995cc - rustc_metadata[7225a1edc81ce069]::rmeta::decoder::cstore_impl::provide_extern::optimized_mir 17: 0x7f6febb992f5 - rustc_query_impl[250cb7a150488de5]::plumbing::__rust_begin_short_backtrace::> 18: 0x7f6feb7bb290 - rustc_query_system[7ef52ba0f7b4d7c0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[250cb7a150488de5]::plumbing::QueryCtxt, true> 19: 0x7f6feb7b872b - rustc_query_impl[250cb7a150488de5]::query_impl::optimized_mir::get_query_incr::__rust_end_short_backtrace 20: 0x7f6febbac55d - ::instance_mir 21: 0x7f6fec26dc28 - rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_items_rec::{closure#0} 22: 0x7f6feb48a707 - rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_items_rec 23: 0x7f6feb48ae91 - rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_items_rec 24: 0x7f6feb48ae91 - rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_items_rec 25: 0x7f6feb48ae91 - rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_items_rec 26: 0x7f6fea7b5704 - rayon[92163da674b3e24f]::iter::plumbing::bridge_producer_consumer::helper::, rayon[92163da674b3e24f]::iter::for_each::ForEachConsumer, rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}>> 27: 0x7f6fea7bcf2d - , rayon[92163da674b3e24f]::iter::for_each::ForEachConsumer, rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}>>::{closure#1}>::{closure#0}, ()> as rayon_core[36277e153e91b8ec]::job::Job>::execute 28: 0x7f6fe9c8e3c9 - ::wait_until_cold 29: 0x7f6fea7b9388 - rayon_core[36277e153e91b8ec]::join::join_context::, rayon[92163da674b3e24f]::iter::for_each::ForEachConsumer, rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}>>::{closure#0}, rayon[92163da674b3e24f]::iter::plumbing::bridge_producer_consumer::helper, rayon[92163da674b3e24f]::iter::for_each::ForEachConsumer, rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}>>::{closure#1}, (), ()>::{closure#0} 30: 0x7f6fea7b58d1 - rayon[92163da674b3e24f]::iter::plumbing::bridge_producer_consumer::helper::, rayon[92163da674b3e24f]::iter::for_each::ForEachConsumer, rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}>> 31: 0x7f6fea7b9417 - rayon_core[36277e153e91b8ec]::join::join_context::, rayon[92163da674b3e24f]::iter::for_each::ForEachConsumer, rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}>>::{closure#0}, rayon[92163da674b3e24f]::iter::plumbing::bridge_producer_consumer::helper, rayon[92163da674b3e24f]::iter::for_each::ForEachConsumer, rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}>>::{closure#1}, (), ()>::{closure#0} 32: 0x7f6fea7b58d1 - rayon[92163da674b3e24f]::iter::plumbing::bridge_producer_consumer::helper::, rayon[92163da674b3e24f]::iter::for_each::ForEachConsumer, rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}>> 33: 0x7f6fea7bcf2d - , rayon[92163da674b3e24f]::iter::for_each::ForEachConsumer, rustc_monomorphize[d5fadf6a90eab74c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}>>::{closure#1}>::{closure#0}, ()> as rayon_core[36277e153e91b8ec]::job::Job>::execute 34: 0x7f6fe9c8e3c9 - ::wait_until_cold 35: 0x7f6fe9c8b2e9 - ::run 36: 0x7f6fea0c9057 - <::spawn<::build_scoped, rustc_driver_impl[ee4d79150a07c4f8]::run_compiler::{closure#0}>::{closure#1}, core[2498b3506ce20dac]::result::Result<(), rustc_span[72d27a3883823780]::ErrorGuaranteed>>::{closure#3}::{closure#0}::{closure#0}, rustc_interface[ad92266d8770ef5]::util::run_in_thread_pool_with_globals, rustc_driver_impl[ee4d79150a07c4f8]::run_compiler::{closure#0}>::{closure#1}, core[2498b3506ce20dac]::result::Result<(), rustc_span[72d27a3883823780]::ErrorGuaranteed>>::{closure#3}::{closure#0}::{closure#1}, core[2498b3506ce20dac]::result::Result<(), rustc_span[72d27a3883823780]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#0} as core[2498b3506ce20dac]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 37: 0x7f6fea0c171e - std[c3fbaf9a0386b13c]::sys::backtrace::__rust_begin_short_backtrace:: + core[2498b3506ce20dac]::marker::Send>, ()> 38: 0x7f6fea0c8d05 - <::spawn_unchecked_ + core[2498b3506ce20dac]::marker::Send>, ()>::{closure#2} as core[2498b3506ce20dac]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 39: 0x7f6fe6d698cb - as core::ops::function::FnOnce>::call_once::h415b3c48feec9148 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/alloc/src/boxed.rs:2062:9 40: 0x7f6fe6d698cb - as core::ops::function::FnOnce>::call_once::h0d4446e047e96116 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/alloc/src/boxed.rs:2062:9 41: 0x7f6fe6d698cb - std::sys::pal::unix::thread::Thread::new::thread_start::h01071f1a69504322 at /rustc/59e2c01c2217a01546222e4d9ff4e6695ee8a1db/library/std/src/sys/pal/unix/thread.rs:108:17 42: 0x7f6fe6b47272 - start_thread 43: 0x7f6fe6bc2dec - __GI___clone3 44: 0x0 - rustc version: 1.81.0-nightly (59e2c01c2 2024-06-17) platform: x86_64-unknown-linux-gnu query stack during panic: #0 [optimized_mir] optimizing MIR for `::default` #1 [collect_and_partition_mono_items] collect_and_partition_mono_items #2 [exported_symbols] collecting exported symbols for crate `0` end of query stack ```

Running the build again did not hit the same error.

alecmocatta commented 1 week ago

Ditto, similar ICE compiling a proprietary codebase. This was on CI. Rerunning on the same commit then succeeded.

https://github.com/rust-lang/rust/blob/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_data_structures/src/sync.rs#L338

https://github.com/rust-lang/rust/blob/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_middle/src/mir/interpret/mod.rs#L538

https://github.com/rust-lang/rust/blob/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_middle/src/mir/interpret/mod.rs#L280

Details ```text thread 'rustc' panicked at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_data_structures/src/sync.rs:338:42: assertion failed: *old == value stack backtrace: 0: rust_begin_unwind at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/panicking.rs:661:5 1: core::panicking::panic_fmt at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/panicking.rs:74:14 2: core::panicking::panic at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/panicking.rs:148:5 3: ::set_alloc_id_same_memory 4: ::decode_alloc_id 5: >::decode.warm 6: >::decode 7: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::optimized_mir [... omitted 1 frame ...] 8: ::instance_mir 9: ::try_inlining 10: ::process_blocks 11: ::run_pass 12: rustc_mir_transform::pass_manager::run_passes_inner 13: rustc_mir_transform::optimized_mir [... omitted 1 frame ...] 14: rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0} 15: rayon::iter::plumbing::bridge_producer_consumer::helper::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>> 16: rayon_core::join::join_context::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#0}, rayon::iter::plumbing::bridge_producer_consumer::helper>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#1}, (), ()>::{closure#0} 17: rayon::iter::plumbing::bridge_producer_consumer::helper::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>> 18: rayon_core::join::join_context::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#0}, rayon::iter::plumbing::bridge_producer_consumer::helper>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#1}, (), ()>::{closure#0} 19: rayon::iter::plumbing::bridge_producer_consumer::helper::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>> 20: rayon_core::join::join_context::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#0}, rayon::iter::plumbing::bridge_producer_consumer::helper>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#1}, (), ()>::{closure#0} 21: rayon::iter::plumbing::bridge_producer_consumer::helper::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>> 22: rayon_core::join::join_context::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#0}, rayon::iter::plumbing::bridge_producer_consumer::helper>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#1}, (), ()>::{closure#0} 23: rayon::iter::plumbing::bridge_producer_consumer::helper::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>> 24: rayon_core::join::join_context::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#0}, rayon::iter::plumbing::bridge_producer_consumer::helper>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#1}, (), ()>::{closure#0} 25: rayon::iter::plumbing::bridge_producer_consumer::helper::>, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>> 26: >, rayon::iter::map::MapConsumer>, rustc_metadata::rmeta::encoder::prefetch_mir::{closure#0}>::{closure#0}::{closure#0}>, >::key_ref>>::{closure#1}>::{closure#0}, ()> as rayon_core::job::Job>::execute 27: ::wait_until_cold 28: ::run 29: <::spawn<::build_scoped, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#3}::{closure#0}::{closure#0}, rustc_interface::util::run_in_thread_pool_with_globals, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#3}::{closure#0}::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#0} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 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 `/home/runner/_work/tably/tably/crates/autobahn/rustc-ice-2024-06-29T17_03_15-61567.txt` to your bug report note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C debug-assertions=on -C overflow-checks=off -C strip=debuginfo -Z oom=panic -Z proc-macro-backtrace -Z macro-backtrace -Z threads=8 note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [optimized_mir] optimizing MIR for `std::collections::hash::map::HashMap::::with_capacity` #1 [optimized_mir] optimizing MIR for `::with_capacity` end of query stack ```
ChrisDenton commented 3 days ago

I got an ICE from the OP's code when building tests twice on x86_64-pc-windows-msvc with rustc 1.81.0-nightly (cc8da78a0 2024-07-04):

ICE ``` thread 'rustc' panicked at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e\compiler\rustc_data_structures\src\sync.rs:337:42: assertion failed: *old == value stack backtrace: 0: 0x7ff81a02d5a3 - std::backtrace_rs::backtrace::dbghelp64::trace at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91 1: 0x7ff81a02d5a3 - std::backtrace_rs::backtrace::trace_unsynchronized at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66 2: 0x7ff81a02d5a3 - std::backtrace::Backtrace::create at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\backtrace.rs:331 3: 0x7ff81a02d4ea - std::backtrace::Backtrace::force_capture at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\backtrace.rs:312 4: 0x7fffaadf6545 - memchr 5: 0x7ff81a04846b - alloc::boxed::impl$50::call at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\alloc\src\boxed.rs:2078 6: 0x7ff81a04846b - std::panicking::rust_panic_with_hook at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\panicking.rs:804 7: 0x7ff81a04823f - std::panicking::begin_panic_handler::closure$0 at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\panicking.rs:663 8: 0x7ff81a04567f - std::sys::backtrace::__rust_end_short_backtrace at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\sys\backtrace.rs:171 9: 0x7ff81a047e56 - std::panicking::begin_panic_handler at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\panicking.rs:661 10: 0x7ff81a09dd94 - core::panicking::panic_fmt at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\core\src\panicking.rs:74 11: 0x7ff81a09de3d - core::panicking::panic at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\core\src\panicking.rs:148 12: 0x7fffa97e46a2 - ::set_alloc_id_same_memory 13: 0x7fffa96c89bb - ::decode_alloc_id 14: 0x7fffaa8c87a4 - ::build 15: 0x7fffaa8b4e2e - ::build 16: 0x7fffaa952003 - ::visit_item 17: 0x7fffaa3bda13 - rustc_query_impl[ebda40cb8fea939a]::plumbing::query_key_hash_verify_all 18: 0x7fffaa2ab0ee - rustc_ty_utils[ea289ddf2ac2917d]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack 19: 0x7fffa94e7c35 - rustc_query_impl[ebda40cb8fea939a]::query_system 20: 0x7fffaacd1ff7 - ::instance_mir 21: 0x7fffaa857543 - rustc_monomorphize[662a250e8978a8be]::is_call_from_compiler_builtins_to_upstream_monomorphization 22: 0x7fffaa854e06 - rustc_monomorphize[662a250e8978a8be]::is_call_from_compiler_builtins_to_upstream_monomorphization 23: 0x7fffaa8564de - rustc_monomorphize[662a250e8978a8be]::is_call_from_compiler_builtins_to_upstream_monomorphization 24: 0x7fffabf7bcad - ::get 25: 0x7fffabf85493 - ::get 26: 0x7fffac6995d9 - ::wait_until_cold 27: 0x7fffac695e41 - ::run 28: 0x7fffaadfa03c - memchr 29: 0x7fffaade96fd - memchr 30: 0x7fffaadf9959 - memchr 31: 0x7ff81a05950d - alloc::boxed::impl$48::call_once at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\alloc\src\boxed.rs:2064 32: 0x7ff81a05950d - alloc::boxed::impl$48::call_once at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\alloc\src\boxed.rs:2064 33: 0x7ff81a05950d - std::sys::pal::windows::thread::impl$0::new::thread_start at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\sys\pal\windows\thread.rs:52 34: 0x7ff869a8257d - BaseThreadInitThunk 35: 0x7ff86b40af28 - RtlUserThreadStart rustc version: 1.81.0-nightly (cc8da78a0 2024-07-04) platform: x86_64-pc-windows-msvc query stack during panic: #0 [optimized_mir] optimizing MIR for `fastrand::global_rng::i8` #1 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack ```
jieyouxu commented 3 days ago

Weirdly, I can't repro:

rustc 1.81.0-nightly (c1b336cb6 2024-06-21): cargo +nightly test twice, no repro rustc 1.81.0-nightly (cc8da78a0 2024-07-04): cargo +nightly test twice, no repro

rustc 1.81.0-nightly (cc8da78a0 2024-07-04)
binary: rustc
commit-hash: cc8da78a036dc3c15c35a97651b02af9a6d30c1e
commit-date: 2024-07-04
host: x86_64-pc-windows-msvc
release: 1.81.0-nightly
LLVM version: 18.1.7
ChrisDenton commented 3 days ago

I did have to force it to rebuild by touching a file.

jieyouxu commented 3 days ago

I did have to force it to rebuild by touching a file.

Thanks, that does it for me too:

ICE ``` Compiling rantz_random v0.4.5 (E:\Repos\rantz_random) thread 'rustc' panicked at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e\compiler\rustc_data_structures\src\sync.rs:337:42: assertion failed: *old == value stack backtrace: 0: 0x7ffdfed44d0d - std::backtrace_rs::backtrace::dbghelp64::trace at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91 1: 0x7ffdfed44d0d - std::backtrace_rs::backtrace::trace_unsynchronized at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66 2: 0x7ffdfed44d0d - std::sys::backtrace::_print_fmt at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\sys\backtrace.rs:68 3: 0x7ffdfed44d0d - std::sys::backtrace::_print::impl$0::fmt at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\sys\backtrace.rs:44 4: 0x7ffdfed75399 - core::fmt::rt::Argument::fmt at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\core\src\fmt\rt.rs:173 5: 0x7ffdfed75399 - core::fmt::write at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\core\src\fmt\mod.rs:1174 6: 0x7ffdfed3b341 - std::io::Write::write_fmt at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\io\mod.rs:1835 7: 0x7ffdfed44ae6 - std::sys::backtrace::print at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\sys\backtrace.rs:34 8: 0x7ffdfed47ce8 - std::panicking::default_hook::closure$1 at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\panicking.rs:265 9: 0x7ffdfed47999 - std::panicking::default_hook at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\panicking.rs:292 10: 0x7ffdf1f65c15 - memchr 11: 0x7ffdfed4846b - alloc::boxed::impl$50::call at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\alloc\src\boxed.rs:2078 12: 0x7ffdfed4846b - std::panicking::rust_panic_with_hook at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\panicking.rs:804 13: 0x7ffdfed4823f - std::panicking::begin_panic_handler::closure$0 at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\panicking.rs:663 14: 0x7ffdfed4567f - std::sys::backtrace::__rust_end_short_backtrace at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\sys\backtrace.rs:171 15: 0x7ffdfed47e56 - std::panicking::begin_panic_handler at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\panicking.rs:661 16: 0x7ffdfed9dd94 - core::panicking::panic_fmt at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\core\src\panicking.rs:74 17: 0x7ffdfed9de3d - core::panicking::panic at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\core\src\panicking.rs:148 18: 0x7ffdf09546a2 - ::set_alloc_id_same_memory 19: 0x7ffdf08389bb - ::decode_alloc_id 20: 0x7ffdf1a387a4 - ::build 21: 0x7ffdf1a24e2e - ::build 22: 0x7ffdf1ac2003 - ::visit_item 23: 0x7ffdf152da13 - rustc_query_impl[ebda40cb8fea939a]::plumbing::query_key_hash_verify_all 24: 0x7ffdf141b0ee - rustc_ty_utils[ea289ddf2ac2917d]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack 25: 0x7ffdf0657c35 - rustc_query_impl[ebda40cb8fea939a]::query_system 26: 0x7ffdf1e41ff7 - ::instance_mir 27: 0x7ffdf19c7543 - rustc_monomorphize[662a250e8978a8be]::is_call_from_compiler_builtins_to_upstream_monomorphization 28: 0x7ffdf19c4e06 - rustc_monomorphize[662a250e8978a8be]::is_call_from_compiler_builtins_to_upstream_monomorphization 29: 0x7ffdf19c64de - rustc_monomorphize[662a250e8978a8be]::is_call_from_compiler_builtins_to_upstream_monomorphization 30: 0x7ffdf30ebcad - ::get 31: 0x7ffdf30f01e6 - ::get 32: 0x7ffdf30ebf68 - ::get 33: 0x7ffdf30f01e6 - ::get 34: 0x7ffdf30ebf68 - ::get 35: 0x7ffdf30f5493 - ::get 36: 0x7ffdf38095d9 - ::wait_until_cold 37: 0x7ffdf3805e41 - ::run 38: 0x7ffdf1f6a03c - memchr 39: 0x7ffdf1f596fd - memchr 40: 0x7ffdf1f69959 - memchr 41: 0x7ffdfed5950d - alloc::boxed::impl$48::call_once at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\alloc\src\boxed.rs:2064 42: 0x7ffdfed5950d - alloc::boxed::impl$48::call_once at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\alloc\src\boxed.rs:2064 43: 0x7ffdfed5950d - std::sys::pal::windows::thread::impl$0::new::thread_start at /rustc/cc8da78a036dc3c15c35a97651b02af9a6d30c1e/library\std\src\sys\pal\windows\thread.rs:52 44: 0x7ffe8eee26ad - BaseThreadInitThunk 45: 0x7ffe8fd6a9f8 - RtlUserThreadStart 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 `E:\Repos\rantz_random\rustc-ice-2024-07-05T04_25_58-10060.txt` to your bug report note: compiler flags: --crate-type lib -C opt-level=1 -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on -C linker=rust-lld.exe -C incremental=[REDACTED] -Z share-generics=n -Z threads=0 note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [optimized_mir] optimizing MIR for `fastrand::global_rng::i64` #1 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack error: could not compile `rantz_random` (lib) warning: build failed, waiting for other jobs to finish... ```
saethlin commented 3 days ago

I've minimized this as much as I can. It's quite small now, but still requires two crates and for some reason a path dependency doesn't work. https://github.com/saethlin/rantz_random

The main crate is

pub fn random() {
    fastrand::bool()
}

pub fn seed() {
    fastrand::seed();
}

And the fastrand dependency is

std::thread_local! {
    static RNG: () = ();
}

#[inline]
fn with_rng(f: impl FnOnce()) {
    RNG.with(|_| {
        f()
    })
}

#[inline]
pub fn seed() {
    with_rng(|| {});
}

#[inline]
pub fn bool() {
    with_rng(|| {})
}

And you must have:

For me, the build ICEs about 1 in every 10 compilations, but it is of course random.

saethlin commented 3 days ago

searched nightlies: from nightly-2024-01-01 to nightly-2024-07-04 regressed nightly: nightly-2024-06-05 searched commit range: https://github.com/rust-lang/rust/compare/7c52d2db6348b038276198e88a835125849f322e...a330e49593ee890f9197727a3a558b6e6b37f843 regressed commit: https://github.com/rust-lang/rust/commit/27529d5c2526eab5aa03d765426c44ea55c5d269

bisected with cargo-bisect-rustc v0.6.9 Host triple: x86_64-unknown-linux-gnu Reproduce with: ```bash cargo bisect-rustc --start=2024-01-01 --end=2024-07-04 --script=script ```

So that's https://github.com/rust-lang/rust/pull/125525 which is just a rewrite of the TLS implementation. All that tells me is that the compiler bug here predates that PR.

saethlin commented 3 days ago

Hunh, the ICE goes away if I add -j1 to the cargo build invocation... That seems bad.

saethlin commented 3 days ago

We are interning alloc1 with bytes that are a pointer to alloc2 then trying to re-intern alloc1, but this time it's a pointer to alloc3. But why...

saethlin commented 1 day ago

Ah! Turning off GVN makes the reproducer go away. That explains why this is being reported now.

oli-obk commented 1 day ago

The root cause maybe that alloc id creation is untracked in incremental and only kept sane by stable hashing the GlobalAlloc instead of the raw index. Maybe there are some issues where we somehow leak the actual index

saethlin commented 1 day ago

I've further minimized the library crate to this:

const RNG: fn() = || {};

fn with_rng() {
    let _x = &RNG;
}

pub fn seed() {
    with_rng();
}

pub fn bool() {
    with_rng();
}
saethlin commented 1 day ago

This bisects to a handful of different commits, depending on what I set the start of the range to. I suspect that's because the reproducer relies on MIR inlining, and sometimes the critical inlining of with_rng() into seed and bool is blocked by query cycle avoidance.

@oli-obk I think this is more likely a race condition causing the incremental compilation decoding process to enter an invalid state. Of course I'm no expert on the code here, but the fact that triggering the crash requires multiple -Zthreads and multiple Cargo --jobs seems to point that way. Though I cannot explain why multiple compilers running at once would be relevant.

In a successful build, we decode alloc1 twice, and both times it contains a pointer to alloc2.

In a crashing build, we decode alloc1 twice, and the first time it contains a pointer to alloc2 and the second time, it contains a pointer to alloc3. In addition, every time we hit this code path, we crash: https://github.com/rust-lang/rust/blob/0ca92de4733bf31262200c6d37e722f534cef4bc/compiler/rustc_middle/src/mir/interpret/mod.rs#L256-L258 ... and I've been unable to find any other workload that tickles that line of code.

So based on the available evidence, it looks like this whole concurrent decoding system just doesn't work.

saethlin commented 1 day ago

Yes I realize I'm making the very brave assertion that this PR from 6 years ago is buggy: https://github.com/rust-lang/rust/pull/51060

I created this PR: https://github.com/rust-lang/rust/pull/127442 which moves the lock scope so that instead of permitting racy decoding, the lock prevents racy decoding. This PR fixes the ICE, but I feel like it breaks the original design of the system. But also it seems to be perf-neutral.