nodejs / nodejs/node

Loading an empty externalized builtin aborts the process

Aperta
#64,749 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo l’abort con --node-builtin-modules-path e un lib/path.js vuoto, quindi ispeziona il percorso del loader usando AddExternalizedBuiltin(). Controlla anche le opzioni condivise per i percorsi builtin. Il lavoro è completato quando un builtin vuoto diventa una stringa V8 vuota senza un abort nativo di CHECK; i successivi errori di compilazione o di runtime JavaScript possono rimanere normali.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
65/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.