fix: Prevent stack overflow in recursive const types by 6d7a · Pull Request #169...
source link: https://github.com/rust-lang/rust-analyzer/pull/16915
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
fix: Prevent stack overflow in recursive const types #16915
Merged
Conversation
Contributor
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.
added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label
Member
@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 |
Contributor
Author
@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. |
Member
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. |
Collaborator
☀️ Test successful - checks-actions |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
No one assigned
None yet
No milestone
Successfully merging this pull request may close these issues.
None yet
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK