JSON.parse failure on deeply nested input corrupts the string; later split() returns non-array, then FATAL 'Not a native context' (v26)

Đang mở
#67,287 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, node.js
Lĩnh vực
backend, testing

Hướng nghiên cứu

Start by reproducing the supplied snippet on Node.js v26 and compare its output with v20, v22, and v24; the report points to the V8 JSON parser’s deep-nesting error path and subsequent string split. Trace the parser behavior and the relevant V8 or Node.js regression tests, then add a regression test showing that a caught parse error leaves the input usable by split() and does not abort on exit.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Version

v26.13.0 (official node:26-slim image, V8 14.6.202.34-node.40); also v26.8.1 (Arch Linux package). Not reproducible on v20.20.2, v22.23.4, v24.22.2.

Platform

Linux x86_64

Subsystem

v8

What steps will reproduce the bug?
const t = '[1,\n'.repeat(10000) + '1]';   // nested ~10,000 arrays deep, unclosed
try { JSON.parse(t); } catch {}            // throws (expected)
const s = t.split('\n');
console.log(Array.isArray(s), s.length);   // expected: true 10001

Same result with --no-maglev --no-turbofan.

How often does it reproduce? Is there a required condition?

Every time with the snippet above: a failing JSON.parse on a string nested several thousand levels deep, then split on the same string.

What is the expected behavior? Why is that the expected behavior?

true 10001, as on Node 20, 22 and 24. A caught parse error must not affect later operations on the input string.

What do you see instead?

false 3, then the process aborts on exit:

FATAL ERROR: Context::GetNumberOfEmbedderDataFields Not a native context
 4: v8::Context::GetNumberOfEmbedderDataFields()
 5: node::Environment::GetCurrent(v8::Isolate*)
 6: node::async_context_frame::set(...)
 ...
Aborted (core dumped)

In a larger app the same shape aborted with Check failed: IsName() or a SIGSEGV.

Additional information

Found when a service parsed a ~380 KB model output beginning with [. Our workaround is to check nesting depth before calling JSON.parse. Looks like the JSON parser's stack-overflow path leaves the string (or heap) in a bad state; it may belong upstream in V8.

Ngôn ngữ chính
JavaScript
Star
124k
Fork
38k
Merge trung bình
4 ngày 2 giờ
Pull request đã merge (30 ngày)
266

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nodejs/node

Tất cả issue của nodejs/node

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.