Loading an empty externalized builtin aborts the process
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 122k
- Forks
- 37.3k
- Merge moyen
- 4 j 2 h
- PR mergées (30 j)
- 283
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire l’abandon avec --node-builtin-modules-path et un lib/path.js vide, puis inspectez le chemin du loader à l’aide de AddExternalizedBuiltin(). Vérifiez également les options de chemin builtin partagées. C’est terminé lorsqu’un builtin vide devient une chaîne V8 vide sans abandon natif de CHECK ; les erreurs ultérieures de compilation ou d’exécution JavaScript peuvent rester normales.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, node.js
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 65/100