Skip to content

async_hooks: async hook stack assertion shadows "Maximum call stack size exceeded"Β #36079

@puzpuzpuz

Description

@puzpuzpuz

What steps will reproduce the bug?

'use strict';
const { AsyncLocalStorage } = require('async_hooks');

const als = new AsyncLocalStorage();

function run(count) {
  if (count !== 0) {
    return als.run({}, run, --count);
  }
}
run(1000);

It's enough to run this script with node --stack-size=100 async-hooks-crash.js.

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

RangeError: Maximum call stack size exceeded should be reported in the crash output:

$ node --stack-size=100 async-hooks-crash.js 
...

RangeError: Maximum call stack size exceeded
    ...

What do you see instead?

$ node --stack-size=100 async-hooks-crash.js 
Error: async hook stack has become corrupted (actual: 111, expected: 70)
 1: 0x97e352 node::AsyncHooks::pop_async_context(double) [node]
 2: 0x979587 node::AsyncWrap::PopAsyncContext(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 3: 0xbe369b  [node]
 4: 0xbe4c46  [node]
 5: 0xbe52c6 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
 6: 0x13ff259  [node]

Additional information

This issue was observed in CI runs for #34573 and #35779

Refs: #15448 (the condition is different and that issue was fixed a long time ago)

Metadata

Metadata

Assignees

No one assigned

    Labels

    async_hooksIssues and PRs related to the async hooks subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions