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 when calling into() #955

Closed
AdamJSoftware opened this issue Nov 22, 2022 · 1 comment
Closed

Weird stack overflow issue when calling into() #955

AdamJSoftware opened this issue Nov 22, 2022 · 1 comment

Comments

@AdamJSoftware
Copy link

So I'm reading a postgres row that I have applied row_to_json for. And it returns a serde_json::Value. From there, I want to convert it to my struct. Calling into() causes a stack overflow error. However, converting it to a string first and then calling from_str works perfectly and returns the expected value

    fn from(row: serde_json::Value) -> Self {
        row.into() -> throws a)
        println!("{:#?}", row) -> check b);
        serde_json::from_str(&row.to_string()).unwrap() -> works perfectly returns c); 
    }

a)

thread 'rocket-worker-thread' has overflowed its stack
fatal runtime error: stack overflow
[Finished running. Exit status: 134]

b)

Object {
    "created_at": String("2022-11-21T20:58:21.806086+00:00"),
    "created_by": Number(1),
    "id": Number(1),
    "name": String("some_name"),
    "updated_at": String("2022-11-21T20:58:21.806086+00:00"),
    "updated_by": Number(1),
}

c)

Organization {
        name: "some_name",
    }
@dtolnay
Copy link
Member

dtolnay commented Nov 22, 2022

According to your description, impl Into<Organization> for serde_json::Value is recursing into itself and exhausting the stack. That impl is not a thing that is implemented by serde_json so this doesn't seem like a serde_json issue.

@dtolnay dtolnay closed this as completed Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants