diagnostics_channel: Channel::binding_data_ dangles after environment cleanup, crashing node:sqlite at exit
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
v27.0.0-pre (2dfdb6a4206)
Platform
Darwin 25.6.0 arm64
Subsystem
diagnostics_channel, sqlite
What steps will reproduce the bug?
Channel holds its BindingData as a raw pointer that is never cleared, so any native holder that outlives environment cleanup reads a destroyed object. Here's a replication case using node:sqlite:
const dc = require('node:diagnostics_channel');
const { DatabaseSync } = require('node:sqlite');
dc.subscribe('sqlite.db.query', () => {});
const db = new DatabaseSync(':memory:');
db.exec('CREATE TABLE t(x)');
const ins = db.prepare('INSERT INTO t VALUES (?)');
for (let i = 0; i < 200; i++) ins.run(i);
// Start iterating and abandon it: the statement stays mid-step, so the
// finalize that happens at teardown fires SQLite's profile callback.
const it = db.prepare('SELECT * FROM t').iterate();
it.next();
globalThis.keepAlive = { db, it };
console.log('reached end of script');
How often does it reproduce? Is there a required condition?
Three conditions are required (all included in the example above):
- A subscriber on
sqlite.db.query, so the SQLite profile hook is installed. - A statement left mid-step at exit, so that the finalize during teardown has a started statement to profile.
- No explicit
close(), so the statement is finalized by the destructor chain afterEnvironment::RunCleanup()rather than before it.
What is the expected behavior? Why is that the expected behavior?
Exiting a process that used node:sqlite with a sqlite.db.query subscriber
shouldn't crash.
What do you see instead?
SIGSEGV, exit 139, after the script has finished.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Ejecuta primero la reproducción proporcionada de node:diagnostics_channel y node:sqlite, y luego sigue Channel::binding_data_ a través de Environment::RunCleanup() y del callback de perfil de SQLite. Confirma la corrección con el mismo escenario de salida, incluida una sentencia que quede a mitad de un paso sin close() explícito, y asegúrate de que el proceso termine sin SIGSEGV.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, node.js, sqlite
- Área
- backend, databases, observability
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100