memory allocation crash, freeze. compiler bug, reproducible
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
pub trait TraitItem {}
pub trait TraitInner {
type Encoder;
}
trait Trait {
type X<T>: TraitInner;
fn a<T: TraitItem>() -> <Self::X<T> as TraitInner>::Encoder {
todo!()
}
}
fn a<T: Trait>() {
T::a(); // missing a generic argument.
}
fn main() {}
I expected to see this happen:
compilation fail. T::a(); needs a generic argument.
Instead, this happened:
Freeze and crash after 3~5mins.
output> memory allocation of 12884901888 bytes failed
Meta
rustc --version --verbose:
rustc 1.94.0-nightly (4f14395c3 2025-12-22)
binary: rustc
commit-hash: 4f14395c37db4c1be874e6b0ace6721674223c22
commit-date: 2025-12-22
host: x86_64-pc-windows-msvc
release: 1.94.0-nightly
LLVM version: 21.1.8
I also tried it on stable 1.92.0
Backtrace
memory allocation of 25769803776 bytes failed
stack backtrace:
0: 0x7fff8d23bda2 - std::backtrace_rs::backtrace::win64::trace
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
1: 0x7fff8d23bda2 - std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: 0x7fff8d23bda2 - std::sys::backtrace::_print_fmt
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\sys\backtrace.rs:74
3: 0x7fff8d23bda2 - std::sys::backtrace::impl$0::print::impl$0::fmt
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\sys\backtrace.rs:44
4: 0x7fff8d263bb1 - core::fmt::write
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\core\src\fmt\mod.rs:0
5: 0x7fff8d24bf94 - std::io::default_write_fmt
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\io\mod.rs:639
6: 0x7fff8d24bf94 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\io\mod.rs:1994
7: 0x7fff8d22f18f - std::sys::backtrace::BacktraceLock::print
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\sys\backtrace.rs:47
8: 0x7fff8d22f18f - std::alloc::default_alloc_error_hook
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\alloc.rs:397
9: 0x7fff8d21596c - std::alloc::rust_oom::closure$0
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\alloc.rs:428
10: 0x7fff8d21301f - std::sys::backtrace::__rust_end_short_backtrace<std::alloc::rust_oom::closure_env$0,never$>
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\sys\backtrace.rs:182
11: 0x7fff8d22f21b - std::alloc::rust_oom
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\alloc.rs:424
12: 0x7fff8d216898 - std::alloc::_::__rust_alloc_error_handler
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\alloc.rs:423
13: 0x7fff9144d8c6 - alloc::alloc::handle_alloc_error::rt_error
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\alloc\src\alloc.rs:407
14: 0x7fff9144d8c6 - alloc::alloc::handle_alloc_error
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\alloc\src\alloc.rs:413
15: 0x7fff9144d8e0 - alloc::raw_vec::handle_error
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\alloc\src\raw_vec\mod.rs:845
16: 0x7fff8ca5f118 - <alloc[32b78c042131820c]::raw_vec::RawVec<rustc_infer[2ef3fe7b5af6d2ef]::traits::Obligation<rustc_middle[4507aa17c3a234da]::ty::predicate::Predicate>>>::grow_one
17: 0x7fff8e43fc72 - <rustc_infer[2ef3fe7b5af6d2ef]::infer::type_variable::TypeVariableTable>::equate
18: 0x7fff8e4641e9 - <rustc_infer[2ef3fe7b5af6d2ef]::infer::relate::type_relating::TypeRelating as rustc_type_ir[c154d49aa2decc6a]::relate::TypeRelation<rustc_middle[4507aa17c3a234da]::ty::context::TyCtxt>>::tys
19: 0x7fff8e3a207e - <rustc_trait_selection[7cf490ea1d8c21b5]::traits::fulfill::FulfillProcessor as rustc_data_structures[a277ee3cb8020c61]::obligation_forest::ObligationProcessor>::process_obligation
20: 0x7fff8e21c7fc - <rustc_data_structures[a277ee3cb8020c61]::obligation_forest::ObligationForest<rustc_trait_selection[7cf490ea1d8c21b5]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[7cf490ea1d8c21b5]::traits::fulfill::FulfillProcessor>
21: 0x7fff8e397b0f - <rustc_trait_selection[7cf490ea1d8c21b5]::traits::dyn_compatibility::IllegalRpititVisitor as rustc_type_ir[c154d49aa2decc6a]::visit::TypeVisitor<rustc_middle[4507aa17c3a234da]::ty::context::TyCtxt>>::visit_ty
22: 0x7fff90bf5c97 - <rustc_trait_selection[7cf490ea1d8c21b5]::error_reporting::traits::on_unimplemented::IgnoredDiagnosticOption>::maybe_emit_warning
23: 0x7fff90c0fef5 - <rustc_trait_selection[7cf490ea1d8c21b5]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
24: 0x7fff8d3f87bd - <hashbrown[9136093051120b50]::raw::RawTable<usize>>::reserve_rehash::<indexmap[ec73d677b2bddae6]::map::core::get_hash<(rustc_middle[4507aa17c3a234da]::ty::predicate::Predicate, rustc_middle[4507aa17c3a234da]::traits::ObligationCause), ()>::{closure#0}>
25: 0x7fff8d402190 - rustc_hir_typeck[f794fe6d5536baf2]::typeck
26: 0x7fff8e07ea1b - RINvMs6_NtCsjEjIgJm70IZ_9hashbrown3rawINtB6_8RawTableTTNtNtNtCs5VrzBvHPef6_12rustc_middle2ty8instance8InstanceNtNtNtBX_3mir4mono14CollectionModeETINtNtNtBX_5query5erase6ErasedAhj20_ENtNtNtCshNWRC7hgUh2_18rustc_query_system9dep_graph5graph12DepNodeIndexEEE1
27: 0x7fff8e1220b2 - RINvNtNtCshNWRC7hgUh2_18rustc_query_system5query8plumbing17try_execute_queryINtCskqlstfJzFev_16rustc_query_impl13DynamicConfigINtNtCsdWOAk63c2pV_21rustc_data_structures9vec_cache8VecCacheNtNtCsgIZ5R5sjmKO_10rustc_span6def_id10LocalDefIdINtNtNtCs5VrzBvHPef6
28: 0x7fff8e157cb2 - rustc_query_impl[ede6e18130cd7241]::plumbing::query_key_hash_verify_all
29: 0x7fff8d5b3ead - rustc_hir_analysis[a4f86372022e8a93]::check_crate
30: 0x7fff8d2968c2 - rustc_interface[4ed039da73a99626]::passes::analysis
31: 0x7fff8cc9297a - <rustc_lint[f03cfdcd39272055]::builtin::SpecialModuleName as rustc_lint[f03cfdcd39272055]::passes::EarlyLintPass>::check_crate
32: 0x7fff8cc9cba3 - RINvNtNtCshNWRC7hgUh2_18rustc_query_system5query8plumbing17try_execute_queryINtCskqlstfJzFev_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs5VrzBvHPef6_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
33: 0x7fff8cd7bad3 - rustc_query_impl[ede6e18130cd7241]::profiling_support::alloc_self_profile_query_strings
34: 0x7fff8a7ba8b1 - std[c408b2fec0bd27e4]::sys::backtrace::__rust_begin_short_backtrace::<std[c408b2fec0bd27e4]::thread::lifecycle::spawn_unchecked<ctrlc[f1ecb5857ba832a7]::set_handler_inner<rustc_driver_impl[28ea21ef32bc2990]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
35: 0x7fff8a7b52bf - RINvNtNtCsgPu1A1epAMW_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCs6LwlKu3Lu2U_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCs3vMOzKSVgQu_17rustc_driver_i
36: 0x7fff8a7c11e9 - std[c408b2fec0bd27e4]::sys::backtrace::__rust_begin_short_backtrace::<std[c408b2fec0bd27e4]::thread::lifecycle::spawn_unchecked<ctrlc[f1ecb5857ba832a7]::set_handler_inner<rustc_driver_impl[28ea21ef32bc2990]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
37: 0x7fff8d2392a8 - std::sys::thread::windows::impl$0::new::thread_start
at /rustc/4f14395c37db4c1be874e6b0ace6721674223c22/library\std\src\sys\thread\windows.rs:58
38: 0x7ff85a63e8d7 - BaseThreadInitThunk
39: 0x7ff85bccc48c - RtlUserThreadStart
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Compile the provided reproducer on the reported stable and nightly versions, then use the backtrace to begin in rustc_hir_typeck::typeck and the rustc_infer and rustc_trait_selection frames. Confirm the problematic case reaches the reported allocation growth; done means rustc promptly reports the missing generic argument instead of freezing or exhausting memory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100