-
Notifications
You must be signed in to change notification settings - Fork 13.3k
1000 fields + #derive(PartialEq) => stack overflow at compile time #40119
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
Comments
For me 654 fields suffice for overflow Rustc stack. The problem is more general: how to test/modify Rustc to be sure there aren't many other similar stack overflows? |
I suspect it's a recursion that's dependent on the number of fields. Recursion seems elegant, but in languages without TCO it's more of a liability than anything, I think. |
Debugger pointed out |
How do you fuzzy-test Rustc to discover many of such cases of possible stack overflow? |
So this probably affects any long chain of binary operations, since I suspect the derive just expands to
A simpler repro might just generate a long chain of expressions like this. |
@abonander you are right. https://gist.github.com/Insomgla/573a162768a36163a0d9d17ab4fa3c41 And I get the same error. |
My gist is at the exact critical point where the overflow is reported by the compiler on my computer. If I remove 1 operation, I have another failure report. See : https://gist.github.com/Insomgla/ef1de205f587ef64d3b3dd323903dd48 |
Cargo likes to eat error messages. Since you've got just a single file and no dependencies you can just invoke The exact point that it overflows is highly dependent on environment as each OS sets a different default stack size for new threads. If you set a much larger default stack size it'll probably compile successfully. That's the difference between deep and infinite recursion. So it's looking like HIR expression lowering needs to be refactored to eliminate the recursion. Probably not a hard job, something that could be mentored maybe. |
It's also quite good to look for all the similar bugs in the codebase. |
Yeah, but these things can be addressed incrementally. It may be a good idea to form a metabug tracking deep recursion issues in the compiler. |
@abonander thanks for the information :p |
You use a crate like |
So how do we handle this ? |
I can't reproduce this with |
Source
The text was updated successfully, but these errors were encountered: