Repository navigation
Conversation
Original commit message:
[json] Stringify: Bailout to slow-path if a string could exceed max len
For strings that might require escaping, we calculate a pessimistic max
length. This allows us to avoid any bounds checks when writing to the
buffer.
However this pessimistic max length can be greater than the allowed
string max length (and even greater than INT_MAX), which could cause
zone allocation to fail.
To avoid zone allocation failure, we fall-back to the slow path if the
pessimistic max length exceeds the allowed string max length.
Fixed: 568816246
Change-Id: I496c34084bce56faad740ad4e139373d6d792552
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8529766
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Patrick Thier <pthier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#110411}
Refs: v8/v8@8a1da7c
Fixes: nodejs#66489
JSON.stringify() of a flat string of 134217726 two-byte or 268435451 one-byte characters aborted the process with "Zone Allocation failed". Check that it returns the result, also for an object value and a property key, and that a result over the maximum string length throws a RangeError. Refs: nodejs#66489
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.
same fix as the v26.13.0 branch, on nodejs/node
mainat f4e89e7 (V8 15.6.75.50): cherry-pick of v8/v8@8a1da7c84be7 (https://chromium-review.googlesource.com/c/v8/v8/+/8529766) soJSON.stringifyof a big flat string falls back to the slow path instead of aborting withZone Allocation failed, plustest/pummel/test-json-stringify-large-flat-string.js. refs nodejs#66489maingets this commit anyway with the V8 15.8 update (nodejs#67070), and Node's V8 guide says not to backport single patches tomain, so upstream thev26.x-stagingbranch is the one that matters. this one is here for the test commit and in case someone wants it onmainearly