SIGBUS on aarch64-apple-darwin during deep nominal trait projection with elevated recursion_limit
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Note / Full transparency: I was running an experiment with an AI coding agent stress-testing compiler recursion limits on my Mac, and the agent produced and minimized this crash reproducer. If this is already a known stack-overflow issue under high
recursion_limitor considered unintended AI noise/slop, please feel free to close/delete it right away! I just wanted to share the minimal reproducer in case it's helpful.
Code
Save the following 10 lines as reproduce.rs:
#![recursion_limit = "10000000"]
pub struct S<T>(std::marker::PhantomData<T>);
pub trait Trait { type Out; }
impl Trait for () { type Out = (); }
impl<T: Trait> Trait for S<T> { type Out = S<<T as Trait>::Out>; }
type N1<T> = S<S<S<S<S<S<S<S<S<S<T>>>>>>>>>>;
type N2<T> = N1<N1<N1<N1<N1<N1<N1<N1<N1<N1<T>>>>>>>>>>;
type N3<T> = N2<N2<N2<N2<N2<N2<N2<N2<N2<N2<T>>>>>>>>>>;
type N4<T> = N3<N3<N3<N3<N3<N3<N3<N3<N3<N3<T>>>>>>>>>>;
pub type Trigger = <N4<N4<()>> as Trait>::Out;
Command:
rustc --crate-type=lib reproduce.rs
Meta
rustc --version --verbose:
rustc 1.97.0 (2d8144b78 2026-07-07)
binary: rustc
commit-hash: 2d8144b7880597b6e6d3dfd63a9a9efae3f533d3
commit-date: 2026-07-07
host: aarch64-apple-darwin
release: 1.97.0
LLVM version: 22.1.6
Error output
error: rustc interrupted by SIGBUS, printing backtrace
0 librustc_driver-22cdaff06538ddcd.dylib _RNvNtCs3Z9OGp4qESS_17rustc_driver_impl14signal_handler17print_stack_trace + 140
1 libsystem_platform.dylib _sigtramp + 56
2 librustc_driver-22cdaff06538ddcd.dylib _RNvXs_NtCs4scqkk2JIvp_10rustc_lint5early...
...
Process exits with exit code 138 (Signal 10 / SIGBUS).
Note / Observation
When recursion_limit is raised, trait projection in rustc_trait_selection::traits::project recurses until the thread stack exhausts the Darwin 8 MB main thread stack and hits the guard page (KERN_PROTECTION_FAILURE). Ideally, the compiler would detect stack depth before triggering a hard OS bus error.
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
Save the supplied reproducer as reproduce.rs and run rustc --crate-type=lib reproduce.rs on the reported target to confirm the SIGBUS. Read rustc_trait_selection::traits::project and the recursion-limit or stack-depth handling it reaches. Done means the compiler handles this deep projection without a hard SIGBUS, with appropriate diagnostic or controlled failure behavior.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100