node/test/node-api/test_instance_data/binding.gyp
Gabriel Schulhof 884e287199 n-api: free instance data as reference
Instance data associated with a `napi_env` is no longer stored on the
env itself but is instead rendered as a reference. Since
`v8impl::Reference` is tied to a JS object, this modification factors
out the `v8impl::Reference` refcounting and the deletion process into
a base class for `v8impl::Reference`, called `v8impl::RefBase`. The
instance data is then stored as a `v8impl::RefBase`, along with other
references, preventing a segfault that arises from the fact that, up
until now, upon `napi_env` destruction, the instance data was freed
after all references had already been forcefully freed. If the addon
freed a reference during the `napi_set_instance_data` finalizer
callback, such a reference had already been freed during environment
teardown, causing a double free.

Re: https://github.com/nodejs/node-addon-api/pull/663
PR-URL: https://github.com/nodejs/node/pull/31638
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-02-06 12:43:24 -08:00

25 lines
401 B
Python

{
"targets": [
{
"target_name": "test_instance_data",
"sources": [
"test_instance_data.c"
]
},
{
"target_name": "test_set_then_ref",
"sources": [
"addon.c",
"test_set_then_ref.c",
]
},
{
"target_name": "test_ref_then_set",
"sources": [
"addon.c",
"test_ref_then_set.c",
]
},
]
}