Repository navigation
Grow the stack in the translator's recursion - #157
Merged
Merged
Conversation
There was a problem hiding this comment.
These duplicates are not on lines GitHub shows in this pull request diff, the inline comment cannot attach there. The links point at the copies on the head commit.
- group context
src/impls/translator_impls/rls.rs:1353-1371pg2sqlite::impls::translator_impls::rls::transform_expr_generic - group context
src/impls/translator_impls/expr.rs:3221-3229pg2sqlite::impls::translator_impls::expr::translate_binary_op
and 1 more, they are in the run summary https://github.com/connetto-rs/pg2sqlite/actions/runs/40128865125
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
A left-deep chain such as `a + a + … + a` aborted the process with a stack overflow, which no caller can catch, at 74 operands in a release build and 13 in a debug build on a 2 MiB thread. sqlparser reads such chains iteratively, so it accepts them at any length and hands over a tree the translator then walks recursively. Every recursion cycle of the forward and reverse translators now carries `#[recursive]` under the `std` feature, the same guard sqlparser's `recursive-protection` uses. Statement translation also raises `recursive`'s minimum headroom to 256 KiB, because one step of the expression translator takes about 140 KiB in a debug build. The same chains now translate past 1,800 operands in release and about 350 in debug, and the remaining aborts happen in sqlparser's derived `Clone` and in sql-traits.
LucaCappelletti94
force-pushed
the
fix/translator-stack-depth
branch
from
October 25, 2026 22:06
0affff8 to
481077e
Compare
There was a problem hiding this comment.
These duplicates are not on lines GitHub shows in this pull request diff, the inline comment cannot attach there. The links point at the copies on the head commit.
- group context
src/impls/translator_impls/rls.rs:1353-1371pg2sqlite::impls::translator_impls::rls::transform_expr_generic - group context
src/impls/translator_impls/expr.rs:3221-3229pg2sqlite::impls::translator_impls::expr::translate_binary_op
and 1 more, they are in the run summary https://github.com/connetto-rs/pg2sqlite/actions/runs/40238648338
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.
A left-deep chain such as
a + a + … + aaborted the process with a stack overflow, which no caller can catch, at 74 operands in a release build and 13 in a debug build on a 2 MiB thread. sqlparser reads such chains iteratively, so it accepts them at any length and hands over a tree the translator then walks recursively.Every recursion cycle of the forward and reverse translators now carries
#[recursive]under thestdfeature, the same guard sqlparser'srecursive-protectionuses. Statement translation also raisesrecursive's minimum headroom to 256 KiB, because one step of the expression translator takes about 140 KiB in a debug build. The same chains now translate past 1,800 operands in release and about 350 in debug. The remaining aborts happen in sqlparser's derivedCloneand in sql-traits, and will be reported upstream.