Loading an empty externalized builtin aborts the process
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.4k
- Merge trung bình
- 4 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 272
Mô tả
Version
latest main branch
Platform
7.1.4-arch1-1
Subsystem
No response
What steps will reproduce the bug?
Build Node.js using --node-builtin-modules-path:
./configure --node-builtin-modules-path=/path/to/node/source
make -j4
Replace a builtin source file with an empty file, then load that builtin:
/path/to/node/source/lib/path.js
out/Release/node -e "require('path')"
The same issue can occur when an empty file is supplied through one of the
shared builtin path options, such as:
--shared-builtin-undici/undici-path
--shared-builtin-amaro/dist/index-path
How often does it reproduce? Is there a required condition?
Every
What is the expected behavior? Why is that the expected behavior?
An empty builtin source should be represented as an empty V8 string.If the empty source is not a valid implementation of that builtin, Node.js may subsequently report a normal JavaScript compilation or runtime error, but it should not terminate due to a native V8 CHECK.
What do you see instead?
The process aborts in v8::String::NewExternalTwoByte() because V8 checks that the external string resource has a non-null data pointer:
Additional information
That check was removed during the external resource lifetime refactoring in PR #47055.
PR #60518 later changed the --node-builtin-modules-path loader to use AddExternalizedBuiltin(), exposing the same issue through dynamically loaded builtin modules. Before that change, this path used String::NewFromUtf8(),which handled empty source files.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện lỗi abort với --node-builtin-modules-path và một lib/path.js rỗng, sau đó kiểm tra đường dẫn loader bằng AddExternalizedBuiltin(). Đồng thời kiểm tra các tùy chọn đường dẫn builtin dùng chung. Được xem là hoàn thành khi một builtin rỗng trở thành một chuỗi V8 rỗng mà không gây abort CHECK native; các lỗi biên dịch hoặc runtime JavaScript xảy ra sau đó vẫn có thể giữ nguyên như bình thường.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, node.js
- Lĩnh vực
- backend
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 65/100