mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
c1ee70ec16
Release `Buffer` and `ArrayBuffer` instances that were created through our addon APIs and have finalizers attached to them only after V8 has called the deleter callback passed to the `BackingStore`, instead of relying on our own GC callback(s). This fixes the following race condition: 1. Addon code allocates pointer P via `malloc`. 2. P is passed into `napi_create_external_buffer` with a finalization callback which calls `free(P)`. P is inserted into V8’s global array buffer table for tracking. 3. The finalization callback is executed on GC. P is freed and returned to the allocator. P is not yet removed from V8’s global array buffer table. (!) 4. Addon code attempts to allocate memory once again. The allocator returns P, as it is now available. 5. P is passed into `napi_create_external_buffer`. P still has not been removed from the v8 global array buffer table. 6. The world ends with `Check failed: result.second`. Since our API contract is to call the finalizer on the JS thread on which the `ArrayBuffer` was created, but V8 may call the `BackingStore` deleter callback on another thread, fixing this requires posting a task back to the JS thread. Refs: https://github.com/nodejs/node/issues/32463#issuecomment-625877175 Fixes: https://github.com/nodejs/node/issues/32463 PR-URL: https://github.com/nodejs/node/pull/33321 Reviewed-By: James M Snell <jasnell@gmail.com> |
||
---|---|---|
.. | ||
async-hello-world | ||
async-hooks-id | ||
async-hooks-promise | ||
async-resource | ||
buffer-free-callback | ||
callback-scope | ||
dlopen-ping-pong | ||
errno-exception | ||
force-context-aware | ||
heap-profiler | ||
hello-world | ||
hello-world-function-export | ||
load-long-path | ||
make-callback | ||
make-callback-domain-warning | ||
make-callback-recurse | ||
new-target | ||
node-module-version | ||
non-node-context | ||
not-a-binding | ||
null-buffer-neuter | ||
openssl-binding | ||
openssl-client-cert-engine | ||
openssl-key-engine | ||
parse-encoding | ||
register-signal-handler | ||
repl-domain-abort | ||
stringbytes-external-exceed-max | ||
symlinked-module | ||
uv-handle-leak | ||
worker-addon | ||
worker-buffer-callback | ||
zlib-binding | ||
.gitignore | ||
addon.status | ||
common.gypi | ||
testcfg.py |