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

Stack overflow inside rustc_middle::ty::print::Printer #88664

Closed
Asapin opened this issue Sep 5, 2021 · 3 comments
Closed

Stack overflow inside rustc_middle::ty::print::Printer #88664

Asapin opened this issue Sep 5, 2021 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@Asapin
Copy link

Asapin commented Sep 5, 2021

Getting a stack overflow error even on a simple cargo check if there's too many structs inside the implementation of serde::Deserialize trait.

cargo check
    Checking err v0.1.0 (D:\projects\rust\err)

thread 'rustc' has overflowed its stack
error: could not compile `err`                                                                                                                               

Caused by:
  process didn't exit successfully: `rustc --crate-name err --edition=2018 src\main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C metadata=9fd35313c6199767 -C extra-filename=-9fd35313c6199767 --out-dir D:\projects\rust\err\target\debug\deps -C incremental=D:\projects\rust\err\target\debug\incremental -L dependency=D:\projects\rust\err\target\debug\deps --extern serde=D:\projects\rust\err\target\debug\deps\libserde-5ecaf821eaf01989.rmeta --extern serde_json=D:\projects\rust\err\target\debug\deps\libserde_json-ec8cae54bf55cb2a.rmeta` (exit code: 0xc00000fd, STATUS_STACK_OVERFLOW)

Project to reproduce: link to playground

But if I move all temporary structs out of the fn deserialize<D> method, the error goes away: working version

Crash dump from WinDbg: ~240MB

As far as I can tell, stack overflow happens somewhere inside rustc_middle::ty::print::Printer

@Asapin Asapin added the C-bug Category: This is a bug. label Sep 5, 2021
@hellow554
Copy link
Contributor

Looks like a dup of #87932, but I'm not sure yet

@Asapin
Copy link
Author

Asapin commented Sep 6, 2021

Yes, it does look very similar. Which is weird as I have almost identical to #87932 code in another place, except the amount of enums and structs inside the fn deserialize (2 enums and 4 structs to be precise), and it doesn't cause any errors.

@tmiasko
Copy link
Contributor

tmiasko commented Jan 14, 2022

Fixed in #89738.

@tmiasko tmiasko closed this as completed Jan 14, 2022
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.
Projects
None yet
Development

No branches or pull requests

3 participants