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

Tracking issue for failure on crash of CallbackScope::Close on testing #979

Closed
legendecas opened this issue Apr 24, 2021 · 7 comments
Closed

Comments

@legendecas
Copy link
Member

legendecas commented Apr 24, 2021

Refs: https://github.com/nodejs/node-addon-api/pull/976/files#diff-db9746a1646fe3119716304e4bc4d3fb6a1e8aac5f4ca11da036bb92102dae74R27

Mininal diffs that make test/callback_scope.js crashing:

diff --git a/test/callbackscope.js b/test/callbackscope.js
index 7396482..e561f2c 100644
--- a/test/callbackscope.js
+++ b/test/callbackscope.js
@@ -17,7 +17,30 @@ function checkAsyncHooks() {

 module.exports = require('./common').runTest(test);

-function test(binding) {
+async function test(binding) {
+  const asyncHooks = require('async_hooks');
+
+  async function foo() {
+    return new Promise(resolve => {
+      const hooks = asyncHooks.createHook({
+        destroy() {
+          hooks.disable();
+          resolve();
+        },
+      });
+      hooks.enable();
+    });
+  }
+  {
+    const future = foo();
+    const resource = new asyncHooks.AsyncResource('foo');
+    resource.emitDestroy();
+    await future;
+  }
+  testActual(binding);
+}
+
+function testActual(binding) {
   if (!checkAsyncHooks())
     return;

Crash backtrace:

node[72630]: ../src/api/callback.cc:122:void node::InternalCallbackScope::Close(): Assertion `(env_->execution_async_id()) == (0)' failed.
 1: 0x100096949 node::Abort() [/usr/local/opt/node@14/bin/node]
 2: 0x1000967d2 node::AppendExceptionLine(node::Environment*, v8::Local<v8::Value>, v8::Local<v8::Message>, node::ErrorHandlingMode) [/usr/local/opt/node@14/bin/node]
 3: 0x100005958 node::InternalCallbackScope::Close() [/usr/local/opt/node@14/bin/node]
 4: 0x100005de8 node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/usr/local/opt/node@14/bin/node]
 5: 0x100006069 node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/usr/local/opt/node@14/bin/node]
 6: 0x1000f1da3 node::ProcessEmit(node::Environment*, char const*, v8::Local<v8::Value>) [/usr/local/opt/node@14/bin/node]
 7: 0x100009ece node::EmitBeforeExit(node::Environment*) [/usr/local/opt/node@14/bin/node]
 8: 0x1000ce057 node::NodeMainInstance::Run() [/usr/local/opt/node@14/bin/node]
 9: 0x10007048a node::Start(int, char**) [/usr/local/opt/node@14/bin/node]
10: 0x7fff20630621 start [/usr/lib/system/libdyld.dylib]
fish: Job 1, 'node test/callbackscope.js' terminated by signal SIGABRT (Abort)

Tested Node.js versions:

  • v16.0.0: Crashing
  • v14.16.1: Crashing
  • v12.22.1: Not Crashing, test failed.
@github-actions
Copy link

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@KevinEady
Copy link
Contributor

Hi @legendecas should this have been closed?

@legendecas legendecas reopened this Aug 26, 2021
@legendecas legendecas removed the stale label Aug 26, 2021
@github-actions
Copy link

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

@mhdawson
Copy link
Member

From discussion in the team meeting, we have a work around in main branch so it does not crash there but this is open as we need a better fix.

Not sure if its an issue with how the test is written or an issue in Node.js core yet.

@KevinEady
Copy link
Contributor

Discussed in Node API meeting on 11 Feb: This issue is still being worked on. In order to reproduce the issue, one can apply the diff in the original comment and see if it's still problematic and causing a crash. We need to determine if it's an issue within core or within how we've written the tests.

@legendecas
Copy link
Member Author

Checked with the latest Node.js LTS releases and the problem seems gone. Bisected through history and identified nodejs/node#39135 fixed the problem.

@legendecas
Copy link
Member Author

Confirmed that when await is commented out the problem is gone too. So this is a problem with the old promise hooks. I'm closing this issue since the fix has already shipped with v14 and v16.

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

No branches or pull requests

3 participants