Skip to content
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

'rustc' has overflowed its stack error #39639

Closed
J-F-Liu opened this issue Feb 8, 2017 · 2 comments
Closed

'rustc' has overflowed its stack error #39639

J-F-Liu opened this issue Feb 8, 2017 · 2 comments
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@J-F-Liu
Copy link

J-F-Liu commented Feb 8, 2017

I see this error also reported in other issues, but I think the cause is different. Here is my example code:

#![feature(conservative_impl_trait)]

trait Trait {
    fn method(&self, x: i32) -> i32;
}

impl<F> Trait for F
    where F: Fn(i32) -> i32
{
    fn method(&self, x: i32) -> i32 {
        if x > 0 { self(x - 1) } else { 0 }
    }
}

fn call<T: Trait, F: Fn() -> T>(f: F) -> impl Trait {
    move |x: i32| f().method(x)
}

fn expr() -> impl Trait {
    call(expr)
    // move |x: i32| expr().method(x)
}

fn main() {
    println!("{:?}", expr().method(2));
}
rustc 1.17.0-nightly (ea7a6486a 2017-02-04)

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow

If you uncomment move || expr().method() and comment call(expr) build can success.

@bstrie bstrie added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. B-unstable Blocker: Implemented in the nightly compiler and unstable. and removed B-unstable Blocker: Implemented in the nightly compiler and unstable. labels Mar 27, 2017
@cyplo
Copy link
Contributor

cyplo commented Jun 30, 2017

still happening now with rustc 1.20.0-nightly (f590a44 2017-06-27)

@Mark-Simulacrum Mark-Simulacrum added the A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. label Jul 19, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@cramertj
Copy link
Member

cramertj commented Jan 5, 2018

Dup of #39555 and #38064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants