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

Make sure wrapcallback is used #762

Conversation

gabrielschulhof
Copy link
Contributor

Finalizers are also able to call JS code and therefore throw. Thus, when calling the user's finalizer, we should wrap it in our C++-to-JS-exception converter.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @gabrielschulhof I assume the extra overhead of another call is not going to be significant as finalization is not too common?

@gabrielschulhof
Copy link
Contributor Author

@mhdawson it should be inlined.

@mhdawson
Copy link
Member

mhdawson commented Jul 9, 2020

@gabrielschulhof I assume you mean by the compiler, if so that makes sense as I see you have it marked as inline

@gabrielschulhof
Copy link
Contributor Author

@mhdawson, yeah, sorry, I meant by the compiler.

@gabrielschulhof
Copy link
Contributor Author

I believe this is blocked by #773.

@gabrielschulhof
Copy link
Contributor Author

Rebased on top of #773. I had to change the child process to examine the exception in the process' uncaughtException handler because it cannot be caught otherwise since nodejs/node#34386.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

gabrielschulhof pushed a commit that referenced this pull request Aug 6, 2020
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: #762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
@gabrielschulhof
Copy link
Contributor Author

Landed in cec2c76.

@gabrielschulhof gabrielschulhof deleted the make-sure-wrapcallback-is-used branch August 6, 2020 17:31
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: nodejs/node-addon-api#762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: nodejs/node-addon-api#762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: nodejs/node-addon-api#762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: nodejs/node-addon-api#762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants