rust-lang / rust-lang/rust

thread 'rustc' panicked at compiler\rustc_monomorphize\src\collector.rs:295:51

Open
#140,001 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-ICE S-needs-repro T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
git clone https://github.com/rustp2p/rustp2p/tree/4cd70aad375e27126d5d33c52c211b695550499d
cargo run --example node_kcp_stream -- --peer udp://x.x.x.x:8080 --group-code rust-p2p --id 1024
Meta

rustc --version --verbose:

rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-pc-windows-msvc
release: 1.86.0
LLVM version: 19.1.7
Error output
thread 'rustc' panicked at compiler\rustc_monomorphize\src\collector.rs:295:51:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7ffb3ab717b1 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7ffb3ab717b1 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffb3ab717b1 - std::sys::backtrace::_print_fmt
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\sys\backtrace.rs:66
   3:     0x7ffb3ab717b1 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\sys\backtrace.rs:39
   4:     0x7ffb3aba52ba - core::fmt::rt::Argument::fmt
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\core\src\fmt\rt.rs:177
   5:     0x7ffb3aba52ba - core::fmt::write
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\core\src\fmt\mod.rs:1449
   6:     0x7ffb3ab67537 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\io\mod.rs:1890
   7:     0x7ffb3ab715f5 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\sys\backtrace.rs:42
   8:     0x7ffb3ab74520 - std::panicking::default_hook::closure$0
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\panicking.rs:298
   9:     0x7ffb3ab74311 - std::panicking::default_hook
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\panicking.rs:325
  10:     0x7ffb3c22764f - core[379ed1e85498c8da]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[954f94a5540fbc1c]::Level, &str), usize), <((rustc_lint_defs[954f94a5540fbc1c]::Level, &str), usize) as core[379ed1e85498c8da]::cmp::PartialOrd>::lt>
  11:     0x7ffb3ab751ae - alloc::boxed::impl$30::call
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\alloc\src\boxed.rs:1990
  12:     0x7ffb3ab751ae - std::panicking::rust_panic_with_hook
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\panicking.rs:839
  13:     0x7ffb3ab74ed2 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\panicking.rs:697
  14:     0x7ffb3ab7231f - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\sys\backtrace.rs:168
  15:     0x7ffb3ab74b0e - std::panicking::begin_panic_handler
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\panicking.rs:695
  16:     0x7ffb3db046f1 - core::panicking::panic_fmt
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\core\src\panicking.rs:75
  17:     0x7ffb3db047ad - core::panicking::panic
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\core\src\panicking.rs:145
  18:     0x7ffb3db0466e - core::option::unwrap_failed
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\core\src\option.rs:2015
  19:     0x7ffb3af6dcb9 - rustc_monomorphize[90fde467f2845068]::mono_checks::check_mono_item
  20:     0x7ffb3af6d848 - rustc_monomorphize[90fde467f2845068]::mono_checks::check_mono_item
  21:     0x7ffb3af6321c - rustc_monomorphize[90fde467f2845068]::mono_checks::check_mono_item
  22:     0x7ffb3a4b9da5 - RINvNtNtNtNtCs4M45Py2ANNS_4core5slice4sort6stable9quicksort9quicksortNtNtNtCs2vqUEYxsi4E_12rustc_middle3mir4mono11CodegenUnitNCINvMNtCsdPcZrWPtBQZ_5alloc5sliceSB15_7sort_byNCNvNtCscrMQbMLbhAi_18rustc_monomorphize12partitioning19merge_codegen_unitss4_0E0EB2
  23:     0x7ffb3af6ee59 - rustc_monomorphize[90fde467f2845068]::partitioning::collect_and_partition_mono_items
  24:     0x7ffb3a7776f7 - <alloc[a10a1d58def73cb3]::sync::Arc<rustc_session[19a3b74f3cfc0353]::cstore::CrateSource>>::drop_slow
  25:     0x7ffb3a75ae4d - <alloc[a10a1d58def73cb3]::sync::Arc<rustc_session[19a3b74f3cfc0353]::cstore::CrateSource>>::drop_slow
  26:     0x7ffb3a68ef70 - RINvNtNtCs1bonBNpMvFl_18rustc_query_system5query8plumbing17try_execute_queryINtCs5uFTMav0Vyp_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs2vqUEYxsi4E_12rustc_middle5query5erase6ErasedAhj28_EEKb0_KB3t_KB3t_ENtNtB1f_8plumbing9QueryCt
  27:     0x7ffb3d0d6791 - <rustc_span[feb426b5f536fd7b]::def_id::DefIndex as rustc_query_impl[40004147c2ba326b]::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
  28:     0x7ffb3b9eea3b - rustc_codegen_ssa[127dad73d42d1fb2]::back::symbol_export::exported_symbols_provider_local
  29:     0x7ffb3a77491a - <alloc[a10a1d58def73cb3]::sync::Arc<rustc_session[19a3b74f3cfc0353]::cstore::CrateSource>>::drop_slow
  30:     0x7ffb3a74f1dd - <alloc[a10a1d58def73cb3]::sync::Arc<rustc_session[19a3b74f3cfc0353]::cstore::CrateSource>>::drop_slow
  31:     0x7ffb3a6f8527 - RINvNtNtCs1bonBNpMvFl_18rustc_query_system5query8plumbing17try_execute_queryINtCs5uFTMav0Vyp_16rustc_query_impl13DynamicConfigINtNtCsdmqHcUI6doO_21rustc_data_structures9vec_cache8VecCacheNtNtCslRMtD7Kp4gh_10rustc_span6def_id8CrateNumINtNtNtCs2vqUEYxsi4E_12
  32:     0x7ffb3a79e6c0 - rustc_query_impl[40004147c2ba326b]::query_system
  33:     0x7ffb3bc6eeee - <rustc_metadata[8812c7b17da9c624]::rmeta::encoder::EncodeContext as rustc_span[feb426b5f536fd7b]::SpanEncoder>::encode_symbol
  34:     0x7ffb3a91982d - rustc_metadata[8812c7b17da9c624]::rmeta::encoder::encode_metadata
  35:     0x7ffb3a92255a - rustc_metadata[8812c7b17da9c624]::fs::encode_and_write_metadata
  36:     0x7ffb377ed57f - <rustc_interface[8ba4dc793610d11]::queries::Linker>::codegen_and_build_linker
  37:     0x7ffb377afc67 - RINvNtNtCs95AQCFfcpgw_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsdPcZrWPtBQZ_5alloc5boxed3BoxDINtNtNtCs4M45Py2ANNS_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECs42d
  38:     0x7ffb377a7fff - RINvNtNtCs95AQCFfcpgw_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsdPcZrWPtBQZ_5alloc5boxed3BoxDINtNtNtCs4M45Py2ANNS_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECs42d
  39:     0x7ffb377a0ce9 - RINvNtNtCs95AQCFfcpgw_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCsKsn22XSOmP_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCs42dsZK7oXeC_17rustc_driver_im
  40:     0x7ffb377b49c3 - RINvNtNtCs95AQCFfcpgw_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsdPcZrWPtBQZ_5alloc5boxed3BoxDINtNtNtCs4M45Py2ANNS_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECs42d
  41:     0x7ffb3ab8656d - alloc::boxed::impl$28::call_once
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\alloc\src\boxed.rs:1976
  42:     0x7ffb3ab8656d - alloc::boxed::impl$28::call_once
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\alloc\src\boxed.rs:1976
  43:     0x7ffb3ab8656d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library\std\src\sys\pal\windows\thread.rs:56
  44:     0x7ffbbfdd7374 - BaseThreadInitThunk
  45:     0x7ffbc181cc91 - 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: rustc 1.86.0 (05f9846f8 2025-03-31) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type lib -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 [collect_and_partition_mono_items] collect_and_partition_mono_items
#1 [exported_symbols] collecting exported symbols for crate `0`
end of query stack
error: could not compile `rustp2p` (lib)

Caused by:
  process didn't exit successfully: `C:\Users\DY2024\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name rustp2p --edition=2021 src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=119 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg "feature=\"aes-gcm\"" --cfg "feature=\"default\"" --cfg "feature=\"kcp\"" --cfg "feature=\"ring\"" --cfg "feature=\"use-kcp\"" --check-cfg cfg(docsrs,test) --check-cfg "cfg(feature, values(\"aes-gcm\", \"chacha20-poly1305\", \"default\", \"kcp\", \"ring\", \"use-kcp\"))" -C metadata=17e731cf31f6036d -C extra-filename=-afdff4327a0b8e73 --out-dir D:\rust-workspace\rustp2p\target\debug\deps -C incremental=D:\rust-workspace\rustp2p\target\debug\incremental -L dependency=D:\rust-workspace\rustp2p\target\debug\deps --extern async_shutdown=D:\rust-workspace\rustp2p\target\debug\deps\libasync_shutdown-333f7bb6ac1b04b2.rmeta --extern async_trait=D:\rust-workspace\rustp2p\target\debug\deps\async_trait-e7e703dee0817039.dll --extern bytes=D:\rust-workspace\rustp2p\target\debug\deps\libbytes-d18dcb52e317328a.rmeta --extern crossbeam_queue=D:\rust-workspace\rustp2p\target\debug\deps\libcrossbeam_queue-fad21306d5bb70e8.rmeta --extern crossbeam_utils=D:\rust-workspace\rustp2p\target\debug\deps\libcrossbeam_utils-05ebb9128f5cd03c.rmeta --extern dashmap=D:\rust-workspace\rustp2p\target\debug\deps\libdashmap-59fb4c6b06ec3d1a.rmeta --extern dns_parser=D:\rust-workspace\rustp2p\target\debug\deps\libdns_parser-d3993e19aaabc81a.rmeta --extern flume=D:\rust-workspace\rustp2p\target\debug\deps\libflume-9beb41dd9944ff8b.rmeta --extern futures=D:\rust-workspace\rustp2p\target\debug\deps\libfutures-573ed7291d1bf7cc.rmeta --extern kcp=D:\rust-workspace\rustp2p\target\debug\deps\libkcp-26049e7d94fd9b5e.rmeta --extern log=D:\rust-workspace\rustp2p\target\debug\deps\liblog-0cedae3a88086422.rmeta --extern parking_lot=D:\rust-workspace\rustp2p\target\debug\deps\libparking_lot-aba126dacead5cb4.rmeta --extern rand=D:\rust-workspace\rustp2p\target\debug\deps\librand-97d0e1b09972c6f6.rmeta --extern ring=D:\rust-workspace\rustp2p\target\debug\deps\libring-598abcdea4cdd1ce.rmeta --extern rmp_serde=D:\rust-workspace\rustp2p\target\debug\deps\librmp_serde-ed0f39c9f2890192.rmeta --extern rust_p2p_core=D:\rust-workspace\rustp2p\target\debug\deps\librust_p2p_core-89d578ccea9d033e.rmeta --extern sha2=D:\rust-workspace\rustp2p\target\debug\deps\libsha2-b9d2341a53c76718.rmeta --extern thiserror=D:\rust-workspace\rustp2p\target\debug\deps\libthiserror-6e0a1b328fe61b83.rmeta --extern tokio=D:\rust-workspace\rustp2p\target\debug\deps\libtokio-f77f08d23dc27e37.rmeta --extern tokio_util=D:\rust-workspace\rustp2p\target\debug\deps\libtokio_util-0a0d945d8a0291b5.rmeta -L native=C:\Users\DY2024\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\windows_x86_64_msvc-0.52.6\lib -L native=D:\rust-workspace\rustp2p\target\debug\build\ring-d96fa81d6c6837f7\out` (exit code: 101)
Backtrace

<backtrace>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the panic with the provided rustp2p commit and cargo run command on rustc 1.86.0, then inspect compiler/rustc_monomorphize/src/collector.rs:295:51 and the collect_and_partition_mono_items query. Done means the supplied crate no longer triggers the Option::unwrap panic, with a regression test covering the case if the compiler test suite has an appropriate entry point.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.