nodejs / nodejs/node

Loading an empty externalized builtin aborts the process

Abierto
#64,749 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
JavaScript
Estrellas
122k
Forks
37.3k
Merge medio
4 d 2 h
PR fusionados (30 d)
283

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza reproduciendo el aborto con --node-builtin-modules-path y un lib/path.js vacío; después inspecciona la ruta del loader mediante AddExternalizedBuiltin(). Comprueba también las opciones compartidas de rutas de builtin. Se considera terminado cuando un builtin vacío se convierte en una cadena V8 vacía sin un aborto nativo de CHECK; los errores posteriores de compilación o de ejecución de JavaScript pueden seguir siendo normales.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, node.js
Área
backend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
65/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.