You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
v8: JSON.stringify fast path allocates memory proportional to string length before throwing on a cyclic object #67480
v26.13.1 (V8 14.6.202.34), v26.7.0 (V8 14.6.202.34), v28.0.0-v8-canary2026111459e40f5e3c (V8 16.0.40). v24.22.3 (V8 13.6.233.17) only with --json-stringify-fast-path.
Platform
Linux 7.0.0-42-generic x86_64 (Ubuntu 24.04)
Subsystem
v8 (JSON.stringify fast path)
What steps will reproduce the bug?
// repro.jsconstlen=Number(process.argv[2]??6000)lettext='a'.repeat(len)text=JSON.parse(JSON.stringify(text))// flat sequential stringconstcycle={ text }cycle.self=cycleconstt0=performance.now()try{JSON.stringify(cycle)}catch(err){console.log(`${err.constructor.name} after ${Math.round(performance.now()-t0)} ms`)}
How often does it reproduce? Is there a required condition?
Every run. The object must contain a cycle and a flat string. With a cons string (drop the JSON.parse(JSON.stringify(...)) line) the TypeError is immediate, presumably because cons strings go to the slow path.
Time and peak memory before the TypeError grow linearly with the string length, at roughly 340 bytes of peak RSS per character:
Build
len 600
len 6000
v22.23.5
0 ms, 45 MB
0 ms, 45 MB
v24.22.3
0 ms, 48 MB
0 ms, 47 MB
v24.22.3 --json-stringify-fast-path
212 ms, 192 MB
2635 ms, 2.0 GB
v26.13.1
185 ms, 193 MB
2626 ms, 2.0 GB
v26.13.1 --no-json-stringify-fast-path
0 ms, 51 MB
0 ms, 51 MB
v28.0.0-v8-canary2026111459e40f5e3c
181 ms, 193 MB
2595 ms, 2.0 GB
What is the expected behavior? Why is that the expected behavior?
TypeError: Converting circular structure to JSON right away with constant memory, as with the slow path and Node 22/24 defaults.
What do you see instead?
The fast path keeps serializing the cycle and only throws after allocating memory proportional to the string length. With a 280 KB string the process grows by about 200 MB/s and needs on the order of 90 GB, so in practice it never throws: it exhausts host memory and is OOM-killed. While it runs the main thread is inside v8::internal::FastJsonStringifier<...>::SerializeObject and does not service signals handled in JS, so node --test ignores SIGTERM until SIGKILL.
Additional information
Found through a unit test that asserts JSON.stringify rejects a cyclic input holding a large string (dofastted/vm2api#1061). #66489 is a different failure in the same fast path (abort on a very long flat string). --no-json-stringify-fast-path works around it.
Activity
Renegade334 commentedon Nov 15, 2026
This has been deemed wontfix.
https://issues.chromium.org/issues/572287937