nodejs / nodejs/node

Loading an empty externalized builtin aborts the process

Offen
#64,749 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, den Abbruch mit --node-builtin-modules-path und einer leeren lib/path.js zu reproduzieren, und untersuche dann den Loader-Pfad mithilfe von AddExternalizedBuiltin(). Überprüfe auch die gemeinsamen Optionen für Builtin-Pfade. Erledigt ist es, wenn ein leeres Builtin zu einem leeren V8-String wird, ohne einen nativen CHECK-Abbruch; spätere JavaScript-Kompilierungs- oder Laufzeitfehler dürfen normal bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, node.js
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
65/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.