deno/tests/napi/src
Nathan Whitaker 368eb9073b
fix(napi): Read reference ownership before calling finalizer to avoid crash (#24203)
Fixes #23493.

What was happening here was that napi-rs was freeing the napi reference
([here](19e3488efc/crates/napi/src/bindgen_runtime/mod.rs (L62)))
during its finalize callback (which we call
[here](fb31eaa9ca/cli/napi/js_native_api.rs (L132))).
We then were [reading the `ownership`
field](fb31eaa9ca/cli/napi/js_native_api.rs (L136))
of that freed reference.

For some reason on arm macs the freed memory gets zeroed, so the value
of `ownership` was `0` when we read it (i.e. it was
`ReferenceOwnership::Runtime`). We then freed it again (since we thought
we owned it), causing the segfault.
2024-06-13 22:31:42 +00:00
..
array.rs
arraybuffer.rs
async.rs
bigint.rs
callback.rs
coerce.rs
date.rs
env.rs
error.rs
finalizer.rs
lib.rs chore: enable clippy::print_stdout and clippy::print_stderr (#23732) 2024-05-08 22:45:06 -04:00
make_callback.rs
mem.rs
numbers.rs
object_wrap.rs fix(napi): Read reference ownership before calling finalizer to avoid crash (#24203) 2024-06-13 22:31:42 +00:00
object.rs fix(ext/node): napi_get_element and napi_set_element work with objects (#23713) 2024-05-06 21:22:50 +02:00
primitives.rs
promise.rs
properties.rs
strings.rs
symbol.rs
tsfn.rs
typedarray.rs