FinalizationRegistry callbacks never run: no host cleanup callback is set
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, wasm
- Área
- backend
Línea de trabajo
Start with runtime/event_loop.cpp and the EventLoop::init and EventLoop::run_event_loop entry points named in the proposed fix. Read how the event loop runs js::RunJobs, then compare the SpiderMonkey shell cleanup callback behavior referenced in the issue. Done means queued finalization cleanups run after each microtask checkpoint, with exceptions reported and cleared; verify using the reproduction across repeated calls.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
StarlingMonkey does not call JS::SetHostCleanupFinalizationRegistryCallback, so SpiderMonkey
queues the records of dead FinalizationRegistry targets and nothing ever runs them. The
embedder is expected to run the doCleanup function it is handed (HTML's
HostEnqueueFinalizationRegistryCleanupJob; the SpiderMonkey shell queues it as a task after the
microtask checkpoint, see ShellCleanupFinalizationRegistryCallback / MaybeRunShellTasks in
js/src/shell/js.cpp).
Seen at StarlingMonkey 9dda8ba (the commit ComponentizeJS 0.23.0 pins), SpiderMonkey
FIREFOX_147_0_4_RELEASE_STARLING.
Why it matters beyond user code: the bindings ComponentizeJS generates
(spidermonkey-embedding-splicer/src/bindgen.rs) drop an imported resource handle that was
not disposed explicitly only from a FinalizationRegistry callback. On a long-lived (reused)
instance every such handle stays live until the store's handle limit traps the instance. A
library that evicts a cache from a callback keeps every entry, and each queued record stays in
the GC heap.
Reproduction (a component reused for many calls):
let finalized = 0;
const registry = new FinalizationRegistry(() => { finalized += 1; });
export function handle() {
registry.register({}, 0);
const buffer = new Uint8Array(2 << 20); // enough malloc to start full collections
buffer[0] = 1;
return `${finalized}`;
}
Expected: the count rises after the first full collections. Actual: 0 on every call (we saw
finalized=0 after 1,000 calls while a WeakRef to a dropped object had been cleared, so
collections do run).
Proposed fix (what we carry as a patch, in runtime/event_loop.cpp):
- in
EventLoop::init, set the callback; it appendsdoCleanupto a
PersistentRooted<GCVector<JSFunction *, 0, js::SystemAllocPolicy>>and nothing else
(it is called during GC, so it must not GC); - in
EventLoop::run_event_loop, after eachjs::RunJobsmicrotask checkpoint, swap the queue
out and call each function in its own realm; an exception is reported and cleared, not
propagated; if any ran, loop back for the microtasks they queued.
This runs cleanups as a task after the microtask checkpoint, as the shell does, and before
run_event_loop returns, so an export call that triggered a collection also runs the cleanups
it queued. Happy to open a PR with it.
- Lenguaje dominante
- C
- Estrellas
- 293
- Forks
- 61
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 12
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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.
Más de bytecodealliance/StarlingMonkey
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
bytecodealliance/StarlingMonkey#343 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
bytecodealliance/StarlingMonkey#344 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
bytecodealliance/StarlingMonkey#339 ·
Los mantenedores suelen responder en 1 día
-
The forgiving decoder implementation is ignoring padding and whitespaces in crypto-algorithm.cppAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 52/100
bytecodealliance/StarlingMonkey#338 ·
Los mantenedores suelen responder en 1 día
-
importing keys via jwk formatAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
bytecodealliance/StarlingMonkey#322 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de bytecodealliance/StarlingMonkey
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
zephyrproject-rtos/zephyr#123423 ·
Los mantenedores suelen responder en 2 días
-
dspromote: /etc/exports uses -alldirs on non-mount-point directories, so mountd exports nothingAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
nextbsd/nextbsd-userland#434 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
[YSQL] Local-node initdb reads postgres.bki, but YB clusters bootstrap only from yb_postgres.bkiAbiertoarea/ysql kind/enhancement priority/low status/awaiting-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
yugabyte/yugabyte-db#35763 ·
Los mantenedores suelen responder en 1 día
-
[mimalloc] update to 3.6.0Abiertocategory:port-update
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 2 días