Repository navigation
SetExpr: apply recursive-protection to Display - #2623
Merged
LucaCappelletti94 merged 2 commits intoOct 16, 2026
Merged
Conversation
Printing a long left-deep chain of set operations recurses once per branch through SetExpr's Display and overflows the stack, e.g. a 25,000-branch UNION ALL chain on a 2 MB stack. Expr's Display already carries the recursive-protection attribute; SetExpr's did not.
LucaCappelletti94
requested changes
Oct 14, 2026
LucaCappelletti94
left a comment
Contributor
There was a problem hiding this comment.
Other than the small nit of the comments verbosity, it looks good.
|
|
||
| #[test] | ||
| fn long_set_operation_chain_display_does_not_stack_overflow() { | ||
| // `SetExpr`'s `Display` recurses once per branch of a set-operation chain. |
Contributor
There was a problem hiding this comment.
Reduce a bit the comments verbosity please
Contributor
Author
There was a problem hiding this comment.
Done in 874616e — trimmed the comments down to the small-stack rationale and the iterative-teardown note. Thanks!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2623 +/- ##
==========================================
+ Coverage 81.16% 81.21% +0.05%
==========================================
Files 42 42
Lines 33769 33866 +97
Branches 33769 33866 +97
==========================================
+ Hits 27408 27505 +97
+ Misses 2797 2796 -1
- Partials 3564 3565 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Reduce the comment verbosity: keep only the small-stack rationale and the iterative-teardown note.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Printing a set-operation chain recurses once per branch through
SetExpr'sDisplay(left.fmt(f)), so a long chain overflows the stack: a 25,000-branchUNION ALLchain on a 2 MB release stack, as reported in the review on #2621.Expr'sDisplayalready carries#[cfg_attr(feature = "recursive-protection", recursive::recursive)];SetExpr's did not. This adds the same attribute.Follow-up to the review on #2621 (#2621 (review)):
Tests:
long_set_operation_chain_display_does_not_stack_overflowparses a 25,000-branchUNION ALLchain and prints it on a thread with a 256 KiB stack, so the check does not depend on the platform's default test-thread stack. With the attribute removed, the test binary aborts with a stack overflow (STATUS_STACK_OVERFLOWon Windows); with it, the test passes. The parsed chain is torn down iteratively, because its recursive drop glue would overflow that small stack too — drop is the separate, pre-existing concern noted in the review.Dialects: none