Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.4k
n-api: ensure scope present for finalization#33508
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
mhdawson commented May 22, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
9642cc5 to 6a62c2aComparemhdawson commented May 25, 2020
@addaleax, @gabrielschulhof hoping you can confirm if you think this adds the scope in the right place. While investigating I checked that the status of the env when the assert is hit indicates that we can still call back to JS, which I'm assuming confirms it's ok to have a Scope/allocation. I could see moving the scope out of the loop to reduce overhead, but left it in the loop as that seems safer in terms of memory use. |
gabrielschulhof commented May 26, 2020
We could create a version of
Lines 57 to 65 in 9949a2e
In TSFN's Lines 303 to 313 in 9949a2e
The same is true in TSFN's Lines 318 to 324 in 9949a2e
In Lines 458 to 460 in 9949a2e
In Lines 858 to 871 in 9949a2e
This is the one you want to change. Would it be expensive if we declared both a Lines 270 to 276 in 9949a2e
In Lines 478 to 480 in 9949a2e
|
gabrielschulhof commented May 26, 2020
So, if we can agree in the two places that we can replace with/add a |
addaleax commented May 26, 2020
@gabrielschulhof Just to be explicit here, |
gabrielschulhof commented May 26, 2020
mhdawson commented May 26, 2020
@gabrielschulhof once #33570 lands, I'll update this PR to add CallIntoModuleWithScopes and use it in all places except for napi_module_register_by_symbol and validate that the new test fails without the scopes/passes with them. |
gabrielschulhof commented May 26, 2020
@mhdawson it must also not be used in |
codecov-commenter commented May 27, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Codecov Report
@@ Coverage Diff @@## master #33508 +/- ## ========================================== - Coverage 96.77% 96.77% -0.01% ========================================== Files 202 201 -1 Lines 67129 66642 -487 ========================================== - Hits 64966 64492 -474 + Misses 2163 2150 -13
Continue to review full report at Codecov.
|
Refs: nodejs/node-addon-api#722 Ensure a scope is on stack during finalization as finalization functions can create JS Objects Signed-off-by: Michael Dawson <[email protected]>
mhdawson commented May 29, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@gabrielschulhof I spent some time looking at a common CallIntoModuleWithScopes, however, that required passing in the AsyncResource which is not available at the place I'm trying to fix and due to need for a HandleScope outside of the callInfoModule or not having a CallbackScope only 2 of the other CallIntoModule locations would have used the new method. I think based only something like only 25% of the paths being able to use it, its not worth adding the new function and simply added the HandleScope to the path from which it was missing. |
mhdawson commented May 29, 2020
Think this is now ready to go. Ran the new test with node_g and still passed after the latest change so should be good to go. |
gabrielschulhof left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I nevertheless think we can streamline our use of scopes, but that's beyond the scope purview of this PR 🙂
mhdawson commented Jun 8, 2020
Resume build: https://ci.nodejs.org/job/node-test-pull-request/31772/ |
nodejs-github-bot commented Jun 8, 2020
nodejs-github-bot commented Jun 9, 2020
mhdawson commented Jun 9, 2020
Resume build: https://ci.nodejs.org/job/node-test-pull-request/31804/ |
nodejs-github-bot commented Jun 9, 2020
mhdawson commented Jun 9, 2020
New build since that seems to be what's needed: https://ci.nodejs.org/job/node-test-pull-request/31807/ |
mhdawson commented Jun 9, 2020
Clean CI run landing. |
gabrielschulhof commented Jun 9, 2020
The last build was yellow. I think this can land. |
mhdawson commented Jun 9, 2020
Landed in 362e4a1 |
Refs: nodejs/node-addon-api#722 Ensure a scope is on stack during finalization as finalization functions can create JS Objects Signed-off-by: Michael Dawson <[email protected]> PR-URL: #33508 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: James M Snell <[email protected]>
Refs: nodejs/node-addon-api#722 Ensure a scope is on stack during finalization as finalization functions can create JS Objects Signed-off-by: Michael Dawson <[email protected]> PR-URL: nodejs#33508 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: James M Snell <[email protected]>
Refs: nodejs/node-addon-api#722 Ensure a scope is on stack during finalization as finalization functions can create JS Objects Signed-off-by: Michael Dawson <[email protected]> PR-URL: #33508 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: James M Snell <[email protected]>
Refs: nodejs/node-addon-api#722 Ensure a scope is on stack during finalization as finalization functions can create JS Objects Signed-off-by: Michael Dawson <[email protected]> PR-URL: #33508 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: James M Snell <[email protected]>
Refs: nodejs/node-addon-api#722 Ensure a scope is on stack during finalization as finalization functions can create JS Objects Signed-off-by: Michael Dawson <[email protected]> PR-URL: nodejs#33508 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: James M Snell <[email protected]>
Refs: nodejs/node-addon-api#722 Ensure a scope is on stack during finalization as finalization functions can create JS Objects Signed-off-by: Michael Dawson <[email protected]> PR-URL: #33508 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: James M Snell <[email protected]>
Refs: nodejs/node-addon-api#722 Ensure a scope is on stack during finalization as finalization functions can create JS Objects Signed-off-by: Michael Dawson <[email protected]> PR-URL: #33508 Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: James M Snell <[email protected]>
Spent some time looking at nodejs/node-addon-api#729 which was related to a crash during finalization when using node-addon-api ObjectWrap.
I think it should be fixed in core as opposed to node-addon-api as it should be possible to hit the same problem using N-API directly instead of node-addon-api.
It seems to be more subtle than the scope never being in place. The added is the simplest test that causes the problem to recreate when run under debug and without the change adding the scope.
Refs: nodejs/node-addon-api#722
Ensure a scope is on stack during finalization
as finalization functions can create JS Objects
Signed-off-by: Michael Dawson [email protected]
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes