Title: async_hooks: AsyncResource.runInAsyncScope causes Node process to crash · Issue #31783 · nodejs/node · GitHub
Open Graph Title: async_hooks: AsyncResource.runInAsyncScope causes Node process to crash · Issue #31783 · nodejs/node
X Title: async_hooks: AsyncResource.runInAsyncScope causes Node process to crash · Issue #31783 · nodejs/node
Description: Version: v12.16.0 Platform: Darwin xxxxx 18.7.0 Darwin Kernel Version 18.7.0: Sun Dec 1 18:59:03 PST 2019; root:xnu-4903.278.19~1/RELEASE_X86_64 x86_64 Subsystem: async_hooks What steps will reproduce the bug? There are 2 flavours to the...
Open Graph Description: Version: v12.16.0 Platform: Darwin xxxxx 18.7.0 Darwin Kernel Version 18.7.0: Sun Dec 1 18:59:03 PST 2019; root:xnu-4903.278.19~1/RELEASE_X86_64 x86_64 Subsystem: async_hooks What steps will reprod...
X Description: Version: v12.16.0 Platform: Darwin xxxxx 18.7.0 Darwin Kernel Version 18.7.0: Sun Dec 1 18:59:03 PST 2019; root:xnu-4903.278.19~1/RELEASE_X86_64 x86_64 Subsystem: async_hooks What steps will reprod...
Opengraph URL: https://github.com/nodejs/node/issues/31783
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"async_hooks: AsyncResource.runInAsyncScope causes Node process to crash","articleBody":"* **Version**: v12.16.0\r\n* **Platform**: Darwin xxxxx 18.7.0 Darwin Kernel Version 18.7.0: Sun Dec 1 18:59:03 PST 2019; root:xnu-4903.278.19~1/RELEASE_X86_64 x86_64\r\n* **Subsystem**: async_hooks\r\n\r\n### What steps will reproduce the bug?\r\nThere are 2 flavours to the crash. Run the following simplified code to reproduce.\r\n\r\n**Version 1**:\r\n```javascript\r\n const {AsyncResource} = require('async_hooks');\r\n new AsyncResource('Foo').runInAsyncScope(() =\u003e {throw new Error()});\r\n```\r\n\r\n**Version 2**:\r\n```javascript\r\n const {AsyncResource} = require('async_hooks');\r\n const run = () =\u003e new AsyncResource('Foo').runInAsyncScope(() =\u003e {throw new Error()});\r\n Promise.resolve().then(run).catch(console.log)\r\n```\r\n\r\n### How often does it reproduce? Is there a required condition?\r\nReproduces constantly\r\n\r\n### What is the expected behavior?\r\nFor Node not to crash\r\n\r\n### What do you see instead?\r\nNode process crashes with the following output.\r\n\r\n**Version 1**:\r\n```\r\nWelcome to Node.js v12.16.0.\r\nType \".help\" for more information.\r\n\u003e const {AsyncResource} = require('async_hooks');\r\nundefined\r\n\u003e new AsyncResource('Foo').runInAsyncScope(() =\u003e {throw new Error()});\r\nUncaught Error\r\n at repl:1:55\r\n at AsyncResource.runInAsyncScope (async_hooks.js:176:7)\r\n\u003e Error: async hook stack has become corrupted (actual: 28, expected: 5)\r\n 1: 0x10000b7f1 node::AsyncHooks::pop_async_id(double) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 2: 0x10000189a node::InternalCallbackScope::Close() [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 3: 0x100001b2f node::InternalMakeCallback(node::Environment*, v8::Local\u003cv8::Object\u003e, v8::Local\u003cv8::Function\u003e, int, v8::Local\u003cv8::Value\u003e*, node::async_context) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 4: 0x10001475c node::AsyncWrap::MakeCallback(v8::Local\u003cv8::Function\u003e, int, v8::Local\u003cv8::Value\u003e*) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 5: 0x1001085f2 node::StreamBase::CallJSOnreadMethod(long, v8::Local\u003cv8::ArrayBuffer\u003e, unsigned long, node::StreamBase::StreamBaseJSChecks) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 6: 0x100109f31 node::EmitToJSStreamListener::OnStreamRead(long, uv_buf_t const\u0026) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 7: 0x10010e263 node::LibuvStreamWrap::OnUvRead(long, uv_buf_t const*) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 8: 0x1008c3d8a uv__stream_io [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 9: 0x1008cba7f uv__io_poll [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n10: 0x1008bb036 uv_run [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n11: 0x1000b6836 node::NodeMainInstance::Run() [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n12: 0x10005dd94 node::Start(int, char**) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n13: 0x7fff67e8f3d5 start [/usr/lib/system/libdyld.dylib]\r\n```\r\n\r\n**Version 2**:\r\n```\r\nWelcome to Node.js v12.16.0.\r\nType \".help\" for more information.\r\n\u003e const {AsyncResource} = require('async_hooks');\r\nundefined\r\n\u003e const run = () =\u003e new AsyncResource('Foo').runInAsyncScope(() =\u003e {throw new Error()});\r\nundefined\r\n\u003e Promise.resolve().then(run).catch(console.log)\r\nPromise { \u003cpending\u003e }\r\n\u003e Error\r\n at repl:1:75\r\n at AsyncResource.runInAsyncScope (async_hooks.js:176:7)\r\n at run (repl:1:46)\r\n at processTicksAndRejections (internal/process/task_queues.js:97:5)\r\nnode[78213]: ../src/api/callback.cc:117:void node::InternalCallbackScope::Close(): Assertion `(env_-\u003eexecution_async_id()) == (0)' failed.\r\n 1: 0x100080dde node::Abort() [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 2: 0x100080b86 node::AppendExceptionLine(node::Environment*, v8::Local\u003cv8::Value\u003e, v8::Local\u003cv8::Message\u003e, node::ErrorHandlingMode) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 3: 0x10000194c node::InternalCallbackScope::Close() [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 4: 0x100001b2f node::InternalMakeCallback(node::Environment*, v8::Local\u003cv8::Object\u003e, v8::Local\u003cv8::Function\u003e, int, v8::Local\u003cv8::Value\u003e*, node::async_context) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 5: 0x100001d0f node::MakeCallback(v8::Isolate*, v8::Local\u003cv8::Object\u003e, v8::Local\u003cv8::Function\u003e, int, v8::Local\u003cv8::Value\u003e*, node::async_context) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 6: 0x10003a362 node::Environment::CheckImmediate(uv_check_s*) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 7: 0x1008c0d46 uv__run_check [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 8: 0x1008bb03e uv_run [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n 9: 0x1000b6836 node::NodeMainInstance::Run() [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n10: 0x10005dd94 node::Start(int, char**) [/Users/user/.nvm/versions/node/v12.16.0/bin/node]\r\n11: 0x7fff67e8f3d5 start [/usr/lib/system/libdyld.dylib]\r\n[1] 78213 abort node\r\n```\r\n\r\n### Additional information\r\nSame code works fine with Node 12.15.0.\r\n","author":{"url":"https://github.com/alexandervain","@type":"Person","name":"alexandervain"},"datePublished":"2020-02-14T00:30:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/31783/node/issues/31783"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9710a8d7-b069-6bca-686e-4872c3b0c90c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C0BA:10B1AF:6AB276:8ECB96:6A505010 |
| html-safe-nonce | 0a9e0b24058c0609f9c6f85d69885cd69bf3e372ef8dc121c17e1a4f28a2baf0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEJBOjEwQjFBRjo2QUIyNzY6OEVDQjk2OjZBNTA1MDEwIiwidmlzaXRvcl9pZCI6IjE3MDUwMTMzNzAxNzA2NTg4MzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3dc8861505bc55e098b833192086f508335feb440e21f5959ce2f166fd533193 |
| hovercard-subject-tag | issue:565030622 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/31783/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b4bb923734a1d921e33d6a8ef2631fd1f7d04f373e753aa9d79c5640b8cdc6b6/nodejs/node/issues/31783 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b4bb923734a1d921e33d6a8ef2631fd1f7d04f373e753aa9d79c5640b8cdc6b6/nodejs/node/issues/31783 |
| og:image:alt | Version: v12.16.0 Platform: Darwin xxxxx 18.7.0 Darwin Kernel Version 18.7.0: Sun Dec 1 18:59:03 PST 2019; root:xnu-4903.278.19~1/RELEASE_X86_64 x86_64 Subsystem: async_hooks What steps will reprod... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alexandervain |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5741a45fe07e5f377d0d4c524a92e3056acc51bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width