Repository navigation
fix(native): report deeply nested header values instead of crashing - #1015
Merged
Merged
Conversation
kvlonge
enabled auto-merge (squash)
October 8, 2026 01:21
The native header value parser recursed once per nesting level, so a header value nested about 20,000 levels deep overflowed the stack and crashed discovery under every compiler engine. The parser now refuses to open more than 256 nested containers, the same limit the YAML loader uses. Discovery reports it under each statement's existing header syntax code, naming the file line of the container that is too deep, with help on how to fix it. The in-memory parse entry points run on the discovery worker pool.
Python projected native header values recursively, spending about four frames per call level, so call syntax nested 231 to 256 levels deep raised RecursionError in every engine. The projection now walks values with an explicit stack, and a plain call counts as the two levels it builds (a hook's arguments count as one more), so the 256-level limit measures the values discovery actually produces. Lint suggests the same flatten help for a header nested too deeply.
kvlonge
force-pushed
the
fix/deep-header-nesting
branch
from
October 8, 2026 01:58
c72c027 to
ba15cf7
Compare
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.
Why
A SQLBuild header whose value nests about 20,000 levels deep crashed discovery with a segmentation fault under every compiler engine: the native header value parser recursed once per level and overflowed the stack. Call syntax nested 231–256 levels also raised
RecursionErrorin Python's projection of the parsed values (CHI-547).Changes
MODEL(...) in 'models/orders.sql:3' contains invalid SQLBuild header syntax: values nest deeper than 256 levels, with helpflatten the value so it nests at most 256 levels deep; lint suggests the same help. Rust and Python wrappers produce identical text and help.parse_*_textentry points run on the discovery worker pool.Verification
cargo test --workspace --all-features: depths 128–257, 1k, 20k and 100k per container kind on a 2 MiB thread with a time bound.sqb compilefor lists and for call syntax at 240/256/257/20k under all three engines.make compiler-differential,make compiler-differential-shipped,tests/e2e/scripts/compiler_differential,make test,make check-ci(Rust 1.98.0) and the public-repository scan pass.