Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
n-api: run all finalizers via SetImmediate()#34386
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: run all finalizers via SetImmediate() #34386
Uh oh!
There was an error while loading. Please reload this page.
Conversation
gabrielschulhof commented Jul 16, 2020
@addaleax this changes the gc-tests like test/js-native-api/test_reference significantly, because it involves another iteration of the event loop. |
gabrielschulhof commented Jul 16, 2020
For testing the finalizers we need to move from a model where you
to one where you
|
mhdawson 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
35f55e0 to 539a7ceComparegabrielschulhof commented Jul 16, 2020
@addaleax@mhdawson thanks for reviewing! I moved the test from test_reference to test_exception which already had a similar test, and I updated all other tests involving gc to await the changes expected in response to the gc instead of asserting that they happened. This means that the tests will time out and fail if the effects of the gc are not as expected instead of failing at an assertion. PTAL! |
539a7ce to 738e298CompareThere 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.
This test is moved to its own file (testFinalizerException.js), below.
Flarna commented Jul 17, 2020
Could you please add a little more info in commit message which async hooks error this fixes? |
fbd5a6b to 17c555aComparegabrielschulhof commented Jul 17, 2020
@Flarna I squashed the commits and elaborated in the commit message on the error that is being fixed. |
nodejs-github-bot commented Jul 20, 2020
nodejs-github-bot commented Jul 20, 2020
nodejs-github-bot commented Jul 21, 2020
nodejs-github-bot commented Jul 22, 2020
gabrielschulhof commented Jul 22, 2020
Oh, boy! Looks like I'd better drop that second commit and make it a separate PR 😳 |
17c555a to 19793e5Comparegabrielschulhof commented Jul 22, 2020
Re-wrote the napi/ref benchmark to be async because it was running synchronously and so the |
nodejs-github-bot commented Jul 23, 2020
gabrielschulhof commented Jul 23, 2020
Fixed the linting. |
Throwing an exception from a finalizer can cause the following fatal error: Error: async hook stack has become corrupted (actual: 2, expected: 0) 1: 0x970b5a node::InternalCallbackScope::~InternalCallbackScope() [./node] 2: 0x99dda0 node::Environment::RunTimers(uv_timer_s*) [./node] 3: 0x13d8b22 [./node] 4: 0x13dbe42 uv_run [./node] 5: 0xa57974 node::NodeMainInstance::Run() [./node] 6: 0x9dbc17 node::Start(int, char**) [./node] 7: 0x7f4965417f43 __libc_start_main [/lib64/libc.so.6] 8: 0x96f4ae _start [./node] By nodejs#34341 (comment), calling into JS from a finalizer and/or throwing exceptions from there is not advised, because the stack may or may not be set up for JS execution. The best solution is to run the user's finalizer from a `SetImmediate()` callback. Signed-off-by: Gabriel Schulhof <[email protected]> Fixes: nodejs#34341
a1c9d78 to f04eaa7Comparegabrielschulhof commented Jul 23, 2020
Used |
nodejs-github-bot commented Jul 23, 2020
nodejs-github-bot commented Jul 23, 2020
cb4d479 to 540ec7eComparenodejs-github-bot commented Jul 23, 2020
nodejs-github-bot commented Jul 23, 2020
Throwing an exception from a finalizer can cause the following fatal error: Error: async hook stack has become corrupted (actual: 2, expected: 0) 1: 0x970b5a node::InternalCallbackScope::~InternalCallbackScope() [./node] 2: 0x99dda0 node::Environment::RunTimers(uv_timer_s*) [./node] 3: 0x13d8b22 [./node] 4: 0x13dbe42 uv_run [./node] 5: 0xa57974 node::NodeMainInstance::Run() [./node] 6: 0x9dbc17 node::Start(int, char**) [./node] 7: 0x7f4965417f43 __libc_start_main [/lib64/libc.so.6] 8: 0x96f4ae _start [./node] By #34341 (comment), calling into JS from a finalizer and/or throwing exceptions from there is not advised, because the stack may or may not be set up for JS execution. The best solution is to run the user's finalizer from a `SetImmediate()` callback. Signed-off-by: Gabriel Schulhof <[email protected]> Fixes: #34341 PR-URL: #34386 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
gabrielschulhof commented Jul 24, 2020
Landed in a74a6e3. |
Throwing an exception from a finalizer can cause the following fatal error: Error: async hook stack has become corrupted (actual: 2, expected: 0) 1: 0x970b5a node::InternalCallbackScope::~InternalCallbackScope() [./node] 2: 0x99dda0 node::Environment::RunTimers(uv_timer_s*) [./node] 3: 0x13d8b22 [./node] 4: 0x13dbe42 uv_run [./node] 5: 0xa57974 node::NodeMainInstance::Run() [./node] 6: 0x9dbc17 node::Start(int, char**) [./node] 7: 0x7f4965417f43 __libc_start_main [/lib64/libc.so.6] 8: 0x96f4ae _start [./node] By #34341 (comment), calling into JS from a finalizer and/or throwing exceptions from there is not advised, because the stack may or may not be set up for JS execution. The best solution is to run the user's finalizer from a `SetImmediate()` callback. Signed-off-by: Gabriel Schulhof <[email protected]> Fixes: #34341 PR-URL: #34386 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
SimenB commented Aug 5, 2020
Is this the cause of #34636? |
Throwing an exception from a finalizer can cause the following fatal error: Error: async hook stack has become corrupted (actual: 2, expected: 0) 1: 0x970b5a node::InternalCallbackScope::~InternalCallbackScope() [./node] 2: 0x99dda0 node::Environment::RunTimers(uv_timer_s*) [./node] 3: 0x13d8b22 [./node] 4: 0x13dbe42 uv_run [./node] 5: 0xa57974 node::NodeMainInstance::Run() [./node] 6: 0x9dbc17 node::Start(int, char**) [./node] 7: 0x7f4965417f43 __libc_start_main [/lib64/libc.so.6] 8: 0x96f4ae _start [./node] By #34341 (comment), calling into JS from a finalizer and/or throwing exceptions from there is not advised, because the stack may or may not be set up for JS execution. The best solution is to run the user's finalizer from a `SetImmediate()` callback. Signed-off-by: Gabriel Schulhof <[email protected]> Fixes: #34341 PR-URL: #34386 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
Throwing an exception from a finalizer can cause the following fatal error: Error: async hook stack has become corrupted (actual: 2, expected: 0) 1: 0x970b5a node::InternalCallbackScope::~InternalCallbackScope() [./node] 2: 0x99dda0 node::Environment::RunTimers(uv_timer_s*) [./node] 3: 0x13d8b22 [./node] 4: 0x13dbe42 uv_run [./node] 5: 0xa57974 node::NodeMainInstance::Run() [./node] 6: 0x9dbc17 node::Start(int, char**) [./node] 7: 0x7f4965417f43 __libc_start_main [/lib64/libc.so.6] 8: 0x96f4ae _start [./node] By #34341 (comment), calling into JS from a finalizer and/or throwing exceptions from there is not advised, because the stack may or may not be set up for JS execution. The best solution is to run the user's finalizer from a `SetImmediate()` callback. Signed-off-by: Gabriel Schulhof <[email protected]> Fixes: #34341 PR-URL: #34386 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes