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

thread 'rustc' has overflowed its stack (when using #[derive(serde::Deserialize)] inside a custom Deserialize impl) #81844

Closed
moxian opened this issue Feb 6, 2021 · 4 comments
Labels
A-proc-macros Area: Procedural macros C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@moxian
Copy link
Contributor

moxian commented Feb 6, 2021

Code

struct AB {}

impl<'de> serde::Deserialize<'de> for AB {
    fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        #[derive(serde::Deserialize)]  // comment this out to fix the stack overflow
        struct A2 {}
        
        return Ok(AB{})
    }
}

fn main(){}

playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8bfc3b0d3b728b256df33a4db645302c

Meta

rustc --version --verbose:

rustc 1.50.0-beta.5 (ff5998292 2021-01-05)
binary: rustc
commit-hash: ff59982926d98c8508008f0559f8a055260ac05e
commit-date: 2021-01-05
host: x86_64-pc-windows-msvc
release: 1.50.0-beta.5

(but also present in stable and nightly)

Error output

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
error: could not compile `playground`
@moxian moxian added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 6, 2021
@jonas-schievink jonas-schievink added A-proc-macros Area: Procedural macros I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 6, 2021
@dillona
Copy link
Contributor

dillona commented Feb 8, 2021

cargo-bisect-rustc points to the following commits:

found 6 bors merge commits in the specified range
  commit[0] 2020-04-26UTC: Auto merge of #71593 - Dylan-DPC:rollup-ms7j94u, r=Dylan-DPC
  commit[1] 2020-04-26UTC: Auto merge of #71468 - matthiaskrgr:submodule_upd, r=Dylan-DPC
  commit[2] 2020-04-27UTC: Auto merge of #71600 - Dylan-DPC:rollup-7tvzi9n, r=Dylan-DPC
  commit[3] 2020-04-27UTC: Auto merge of #70073 - wesleywiser:mir_opt_level_0, r=oli-obk
  commit[4] 2020-04-27UTC: Auto merge of #71268 - estebank:devectorize, r=eddyb
  commit[5] 2020-04-27UTC: Auto merge of #71200 - oli-obk:mir_bless, r=eddyb

@apiraino
Copy link
Contributor

apiraino commented Feb 11, 2021

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@apiraino apiraino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 11, 2021
@zugzwang
Copy link

zugzwang commented Mar 2, 2021

Without commenting the derive line, the stack overflow also gets fixed if the definition of A2 gets moved out of the impl scope

Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=3caf353743fc1625b02f50933b6fd348

@dtolnay
Copy link
Member

dtolnay commented Mar 19, 2021

Closing as a duplicate of #55779.

@dtolnay dtolnay closed this as completed Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macros Area: Procedural macros C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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

6 participants