fix(json): parse deep nesting with a heap-backed stack - #7832
Merged
Conversation
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.
Summary
Closes #7817. JSON.parse now switches from the recursive fast path to the existing flat tape representation once nesting passes the worker-stack threshold, then materializes that tape with an explicit heap-backed work stack. The reported 300,000-level document parses on a 2 MiB worker stack.
A separate 500,000-level iterative nesting budget keeps resource use finite and reports a catchable RangeError.
Changes
Related issue
Closes #7817. Follows the crash guard in #7816.
Test plan
The quiet-mini benchmark is pending because its required lock is held by strcat-agent; no performance numbers are claimed here yet.
Screenshots / output
N/A (runtime parser change).
Checklist
Summary by CodeRabbit
New Features
Bug Fixes
RangeErrorinstead of risking parser failure.