Skip to content

Stack overflow due to detected cycle when determining type not directly returned but still unambigous TAIT #140522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cafce25 opened this issue Apr 30, 2025 · 2 comments
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@cafce25
Copy link
Contributor

cafce25 commented Apr 30, 2025

I tried this code:

#![feature(type_alias_impl_trait)]
pub struct Foo<T>(Vec<T>);
pub type FooRet = impl std::future::Future<Output = ()>;
impl Foo<FooRet> {
    #[define_opaque(FooRet)]
    pub fn push(&mut self) {
        self.0.push(async move {});
    }
}

I expected the compiler to be able to figure out the type alias FooRet because there is a single define_opaque function, even if it doesn't directly return the type it's still unambiguous.

Instead, the compiler wound up in a cycle trying to figure out the type, finally it gave the following

compile error:
 Compiling playground v0.0.1 (/playground)
error: rustc interrupted by SIGSEGV, printing backtrace

/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x39cd19f)[0x70f992fcd19f]
/lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x70f98f433330]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(_RNvXs_NtCsgRfd0FldB0E_21rustc_symbol_mangling6legacyNtB4_13SymbolPrinterNtNtNtCsbUf8S3c5VKM_12rustc_middle2ty5print7Printer10path_crate+0x10)[0x70f99103fda0]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x5411f6a)[0x70f994a11f6a]

### cycle encountered after 4 frames with period 5
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x5411cb0)[0x70f994a11cb0]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x54121b1)[0x70f994a121b1]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x540ff0b)[0x70f994a0ff0b]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(_RNvXs_NtCsgRfd0FldB0E_21rustc_symbol_mangling6legacyNtB4_13SymbolPrinterNtNtNtCsbUf8S3c5VKM_12rustc_middle2ty5print7Printer15print_impl_path+0x684)[0x70f994a0ac44]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x5411cb0)[0x70f994a11cb0]
### recursed 49 times

/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x5411cb0)[0x70f994a11cb0]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x541222f)[0x70f994a1222f]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x540ff0b)[0x70f994a0ff0b]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(_RNvXs_NtCsgRfd0FldB0E_21rustc_symbol_mangling6legacyNtB4_13SymbolPrinterNtNtNtCsbUf8S3c5VKM_12rustc_middle2ty5print7Printer15print_impl_path+0x684)[0x70f994a0ac44]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x5411cb0)[0x70f994a11cb0]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x5411cb0)[0x70f994a11cb0]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-3617f6db57c4496d.so(+0x541222f)[0x70f994a1222f]

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
note: backtrace dumped due to SIGSEGV! resuming signal
error: could not compile `playground` (lib)

Meta

Build using the Nightly version: 1.88.0-nightly (2025-04-29 7450913) from the playground.

Example on the Playground

@cafce25 cafce25 added the C-bug Category: This is a bug. label Apr 30, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 30, 2025
@moxian
Copy link
Contributor

moxian commented Apr 30, 2025

@rustbot label: +I-crash +F-type_alias_impl_trait +S-has-mcve +T-types -needs-triage

@rustbot rustbot added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 30, 2025
@oli-obk
Copy link
Contributor

oli-obk commented May 1, 2025

Ugh symbol printing again.

I think this is because the async block has Self as a generic parameter, and that contains the opaque type again.

Yea I am confident this is a duplicate of #136390

@oli-obk oli-obk closed this as completed May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants