deno
764ce2fb - fix(ext/ffi): retain backing store references in nonblocking calls (#32775)

Commit
251 days ago
fix(ext/ffi): retain backing store references in nonblocking calls (#32775) Nonblocking FFI calls extract raw pointers from ArrayBuffer backing stores and send them to a background thread via spawn_blocking, but without retaining a reference to the backing store. If V8's garbage collector runs before the background thread completes, the backing store can be freed, leaving the native code with a dangling pointer. Fix by collecting SharedRef<BackingStore> references alongside the raw pointers for buffer, struct, and out_buffer arguments in nonblocking calls, and moving them into the spawn_blocking closure so they are kept alive for the duration of the native call. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Parents
Loading