rust-lang / rust-lang/rust

stack overflow in trait selection

Open
#141,772 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-crash T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
fn foo() -> typeof(foo) {}
Meta

rustc --version --verbose:

rustc 1.89.0-nightly (1bbd62e54 2025-05-29)
binary: rustc
commit-hash: 1bbd62e547ba5cc08ccb44c27def3d33195d2dd5
commit-date: 2025-05-29
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5
Error output
error[E0516]: `typeof` is a reserved keyword but unimplemented
 --> a.rs:1:13
  |
1 | fn foo() -> typeof(foo) {}
  |             ^^^^^^^^^^^ reserved keyword
Backtrace

error: rustc interrupted by SIGSEGV, printing backtrace

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-ef85d6b35b33584e.so(+0x3b31b7f) [0x732055d31b7f]
/usr/lib/libc.so.6(+0x3def0) [0x73205204def0]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-ef85d6b35b33584e.so(_RNvXs_NtNtCsh5ZT284fzFU_21rustc_trait_selection6traits2wfNtB4_12WfPredicatesINtNtCsl3MoBsZilMd_13rustc_type_ir5visit11TypeVisitorNtNtNtCsl8oLuWw2NAI_12rustc_middle2ty7context6TyCtxtE8visit_ty+0x41) [0x732057ad3d9b]

### cycle encountered after 3 frames with period 4
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-ef85d6b35b33584e.so(_RNvXs_NtNtCsh5ZT284fzFU_21rustc_trait_selection6traits2wfNtB4_12WfPredicatesINtNtCsl3MoBsZilMd_13rustc_type_ir5visit11TypeVisitorNtNtNtCsl8oLuWw2NAI_12rustc_middle2ty7context6TyCtxtE8visit_ty+0x384e) [0x732057ad75a8]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-ef85d6b35b33584e.so(_RNvXs_NtNtCsh5ZT284fzFU_21rustc_trait_selection6traits2wfNtB4_12WfPredicatesINtNtCsl3MoBsZilMd_13rustc_type_ir5visit11TypeVisitorNtNtNtCsl8oLuWw2NAI_12rustc_middle2ty7context6TyCtxtE8visit_ty+0x384e) [0x732057ad75a8]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-ef85d6b35b33584e.so(_RNvXs_NtNtCsh5ZT284fzFU_21rustc_trait_selection6traits2wfNtB4_12WfPredicatesINtNtCsl3MoBsZilMd_13rustc_type_ir5visit11TypeVisitorNtNtNtCsl8oLuWw2NAI_12rustc_middle2ty7context6TyCtxtE8visit_ty+0x384e) [0x732057ad75a8]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-ef85d6b35b33584e.so(_RNvXs_NtNtCsh5ZT284fzFU_21rustc_trait_selection6traits2wfNtB4_12WfPredicatesINtNtCsl3MoBsZilMd_13rustc_type_ir5visit11TypeVisitorNtNtNtCsl8oLuWw2NAI_12rustc_middle2ty7context6TyCtxtE8visit_ty+0x384e) [0x732057ad75a8]
### recursed 63 times

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-ef85d6b35b33584e.so(_RNvXs_NtNtCsh5ZT284fzFU_21rustc_trait_selection6traits2wfNtB4_12WfPredicatesINtNtCsl3MoBsZilMd_13rustc_type_ir5visit11TypeVisitorNtNtNtCsl8oLuWw2NAI_12rustc_middle2ty7context6TyCtxtE8visit_ty+0x384e) [0x732057ad75a8]

note: rustc unexpectedly overflowed its stack! this is a bug
note: maximum backtrace depth reached, frames may have been lost
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
[1]    835817 segmentation fault  RUST_BACKTRACE=full rustc a.rs --crate-type lib

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 with the minimal reproducer in a.rs and run RUST_BACKTRACE=full rustc a.rs --crate-type lib using the reported nightly toolchain. Read the rustc_trait_selection stack frames and the WfPredicates/visit_ty cycle in the backtrace; done means the reproducer no longer overflows the compiler stack or segfaults while producing the expected diagnostic.

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
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.