rust-lang / rust-lang/rust

Stack overflow from closure TAIT in a method on the opaque type itself in debug mode

Open
#144,832 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-type_alias_impl_trait I-crash I-ICE S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
#![feature(type_alias_impl_trait)]

type Opaque = impl Sized;

trait Trait {
    fn foo();
}

impl Trait for Opaque {
    #[define_opaque(Opaque)]
    fn foo() {
        let _: Opaque = || {};
    }
}

fn main() {
    Opaque::foo();
}

@rustbot labels +F-type_alias_impl_trait +I-crash

Crash only occurs when compiling in debug mode

Possibly related to https://github.com/rust-lang/rust/issues/136390

Meta

Reproducible on the playground with version version: 1.90.0-nightly (2025-08-01 4b55fe199cfe9c710555)

Error output
error: rustc interrupted by SIGSEGV, printing backtrace
Backtrace

/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x3c8efcf)[0x7e5504e8efcf]
/lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x7e550102e330]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x67e3c7c)[0x7e55079e3c7c]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e2959d)[0x7e550702959d]

### cycle encountered after 4 frames with period 6
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7e55070256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7e55070256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e29171)[0x7e5507029171]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7e55070256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7e55070256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e29171)[0x7e5507029171]
### recursed 42 times


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
error: could not compile `playground` (bin "playground")

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 Rust reproducer and compile it in debug mode, then compare the behavior in release mode. Inspect the reported recursive backtrace and the related issue #136390 to locate the compiler cycle involving closure TAIT and the opaque type. Done means the reproducer no longer causes rustc to overflow its stack or crash.

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
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.