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

Weird stack overflow issue with single struct #1467

Closed
kardeiz opened this issue Jan 29, 2019 · 2 comments
Closed

Weird stack overflow issue with single struct #1467

kardeiz opened this issue Jan 29, 2019 · 2 comments

Comments

@kardeiz
Copy link

kardeiz commented Jan 29, 2019

When I run the following code:

#[derive(Debug)]
pub struct Foo {
    baz: i32
}

impl serde::Serialize for Foo {
    fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        #[derive(serde_derive :: Serialize)]
        struct Inner<'a>(&'a i32);
        let inner = Inner(&self.baz);
        serde::Serialize::serialize(&inner, serializer)
    }
}

// #[derive(serde_derive::Serialize)]
// pub struct Bar {
//     baz: i32
// }

fn main() {}

I get

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

However, if I uncomment the Bar struct, it runs just fine.

This is with serde 1.0.85. It doesn't seem to be the same as the other open SO issues.

@dtolnay
Copy link
Member

dtolnay commented Jan 29, 2019

This is a compiler bug: rust-lang/rust#55779

@kardeiz
Copy link
Author

kardeiz commented Jan 29, 2019

Okay, thanks for the quick response! Sorry for posting here; I'm not familiar enough with rustc stuff and hadn't encountered this elsewhere. I'll follow the linked issue and close this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants