-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix: Prevent stack overflow in recursive const types #16915
Conversation
In the evaluation of const values of recursive types certain declarations could cause an endless call-loop within the interpreter (hir-ty’s create_memory_map), which would lead to a stack overflow. This commit adds a check that prevents values that contain an address in their value (such as TyKind::Ref) from being allocated at the address they contain. The commit also adds a test for this edge case.
@6d7a Thanks for the PR! I didn't understand how your patch addresses the problem. If I understand correctly, the problem is that In addition to that bug which we need to fix, infinite constants might exist, so we might need to add a depth limit or something like that to the |
@HKalbasi thank you for your review. My reasoning in case of the fix was to prevent that reference values point to the location that they themselves reside in. However I can see that this is more of a hotfix for my particular case instead of a sustainable solution. Too much wishful thinking on my part. |
Thanks!
AFAIK there is no way to create infinite constants in stable Rust, so this is good for now. Though we should find out why it is allocating the same address for different constants, as it can cause problems even without recursive types. |
☀️ Test successful - checks-actions |
In the evaluation of const values of recursive types certain declarations could cause an endless call-loop within the interpreter (hir-ty’s create_memory_map), which would lead to a stack overflow.
This commit adds a check that prevents values that contain an address in their value (such as TyKind::Ref) from being allocated at the address they contain.
The commit also adds a test for this edge case.