Repository navigation
fix(zero-rust): take JSON nested as deep as zero-cache writes - #205
Merged
Merged
Conversation
The parser rejected JSON nested deeper than 1,500 levels, because cloning, comparing, and writing a value recursed and a debug build overflowed a 2 MB thread stack by about 2,400 to 3,500 levels. zero-cache writes up to about 4,100, and JS takes them, so a row with a JSON column nested deeper than 1,500 made the client reject the poke, disconnect, and fail the same way after every reconnect. Clone, PartialEq, and json::write now recurse 128 levels and then go on over a heap stack, and MAX_DEPTH is 5,000. Dropping fits in a 2 MB debug stack at that depth without changes. The conformance runner no longer has a nesting exception: harden-json's 1,502-level case matches JS exactly, and a rejection for depth now counts as a failure. PARITY.md records why the two remaining exceptions (lone surrogates, unwritable JSON paths) stay. Amp-Thread-ID: https://ampcode.com/threads/T-db04f816-97ed-4bc9-b19e-9ee68611a0ab Co-authored-by: tmm <tmm@tmm.dev>
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.
Part of the Rust parity push: clearing the conformance runner's documented exceptions.
Before.
json::parserejected anything nested deeper than 1,500 levels. Cloning, comparing, and writing a value recursed, and a debug build overflowed a 2 MB thread stack at these depths:==zero-cache writes up to about 4,100 levels, and JS accepts all of them. So a row whose JSON column was nested deeper than 1,500 levels got its poke rejected as
InvalidMessage, and the client then disconnected and failed again after every reconnect. Swift has the same 1,500 limit.Now.
Clone,PartialEq, andjson::writerecurse 128 levels deep, then continue over a heap stack. Shallow values keep the recursive code.MAX_DEPTHis 5,000.Debugformatting still recurses.harden-json's 1,502-level case matches JS exactly, and any rejection for depth now counts as a failure.rust/PARITY.mdrecords why the two remaining exceptions stay: lone surrogates (a RustStringcan't hold one) and unwritable JSON paths (a negative or fractional index doesn't type-check).Checks.
clone() == original, it compares unequal to a copy whose innermost value differs, and one more level is rejected.cargo test --workspace,cargo clippy --workspace --all-targets --all-features -D warnings, andcargo doc -D warningspass.main. Everything is within noise or faster (pokes −6 to −8%, first sync −2 to −4%). The 100,000-row materialize timings varied 13–22 ms run to run even onmain. Under callgrind, materializing 100,000 rows three times costs 4,858M instructions, against 4,865M onmain.