-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #72933
Comments
As an experiment I tried doubling the number of enum variants and compiling using stable. That still worked. So it seems the code wasn't just on the brink to stop working using the stable compiler. |
Here is a github repo with a minimized test case for this issue: |
@Mark-Simulacrum It introduced a mechanism for dealing with this kind of issue, but I don’t doubt that we might have missed instances where the compiler is doing something recursive. MIR construction for matches appears to be one of these cases. |
Yeah, that's what I expected, I just recalled seeing some commentary suggesting that we'd perhaps covered all cases. Definitely not unexpected that we didn't, though, nor did I intend to imply we should have :) |
The beta seems to not have the problem. The problem does not occur with "rustc 1.44.0-beta.4 (02c25b3 2020-05-23)". |
I saw the 'E-needs-mcve'-tag. @nagisa Did you see my repro-case? https://github.com/avl/repro_enum_serde_stackoverflow72933 (but maybe you're talking about something more self-contained, not referencing 'serde'?) |
I saw the repo, but it still needs some work to be reduced to a viable regression test case that could be included into the repo along with fix. This is what I’m working on now as I already have the fix itself. |
Assigning |
If anyone else gets here having the same problem, manually implementing Serialize and Deserialize rather than relying on serde-derive, is one way around the problem. I adapted the examples at https://serde.rs/custom-serialization.html for my enum and this made the compile time insignificant. It also improved performance using the old rust considerably. |
Mhh, I remember having seen some other issues related to derive macros recently... cc @petrochenkov, who might know. |
…i-obk Ensure stack when building MIR for matches In particular matching on complex types such as strings will cause deep recursion to happen. Fixes rust-lang#72933 r? @matthewjasper @oli-obk
…i-obk Ensure stack when building MIR for matches In particular matching on complex types such as strings will cause deep recursion to happen. Fixes rust-lang#72933 r? @matthewjasper @oli-obk
In particular matching on complex types such as strings will cause deep recursion to happen. Fixes rust-lang#72933
I just tried the latest nightly (rustc 1.45.0-nightly (ad4bc33 2020-06-01)) and noticed it can't compile one of the crates I work on.
The crate does have an enum with a a huge number of variants (almost 6000), for which I use serde to derive Serialize and Deserialize.
When building, even with just 'cargo check', the build fails with
It works on stable 1.43.1.
I tried running rustc under gdb. It didn't crash exactly the same way, I got SIGSEGV instead.
Looking at the callstack in gdb, it is suspiciously deep (15000 functions deep). The top most functions are:
If I reduce the number of enum variants to 5000, or stop using serde to derive Serialize/Deserialize, it starts working again.
Since it works using stable, but not using nightly, I thought it might be some kind of regression. I totally realize this may not be a bug and that what I'm doing (Serde + giant enum) is just not a good idea. Accept my apologies if this kind of thing shouldn't be reported here!
The text was updated successfully, but these errors were encountered: