deno
802a788d - fix(ext/napi): pass valid env to tsfn call_js_cb after close race (#32957)

Commit
241 days ago
fix(ext/napi): pass valid env to tsfn call_js_cb after close race (#32957) ## Summary - Fix SIGSEGV crash in native addons (e.g. node-pty) caused by a race condition in NAPI threadsafe function teardown - When a tsfn is released while calls are still pending, `TsFn::drop` can run before a queued call is processed. Previously, the `call_js_cb` was invoked with `env=NULL`, crashing addons that dereference env without a null check (SIGSEGV at address 0x90) - Fix captures the env pointer in the call closure so it's available after the TsFn is freed. The env is always valid (leaked via `Box::into_raw`, never freed) and V8 is alive (callback runs on V8 thread) - Add regression test `test_tsfn_close_race` that spawns concurrent calling/releasing threads to exercise the race Towards https://github.com/denoland/deno/issues/32846 --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Parents
Loading