Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n-api: free instance data as reference #31638

Commits on Feb 6, 2020

  1. 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: nodejs/node-addon-api#663
    Gabriel Schulhof committed Feb 6, 2020
    Configuration menu
    Copy the full SHA
    38b4b6f View commit details
    Browse the repository at this point in the history