Loading an empty externalized builtin aborts the process
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、--node-builtin-modules-path と空の lib/path.js を使って abort を再現し、次に AddExternalizedBuiltin() を使って loader のパスを調べます。共有されている builtin パスのオプションも確認します。空の builtin がネイティブな CHECK abort を発生させずに空の V8 文字列になることが完了の条件です。その後の JavaScript のコンパイルエラーやランタイムエラーは通常どおり残っていてかまいません。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, node.js
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 65/100