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

Repl crashes when used with AsyncLocalStorage #38936

Closed
devinivy opened this issue Jun 5, 2021 · 4 comments
Closed

Repl crashes when used with AsyncLocalStorage #38936

devinivy opened this issue Jun 5, 2021 · 4 comments
Labels
async_hooks Issues and PRs related to the async hooks subsystem. confirmed-bug Issues with confirmed bugs.

Comments

@devinivy
Copy link

devinivy commented Jun 5, 2021

  • Version: v16.2.0 (also reproduces on v16.3.0, but not v16.1.0)
  • Platform: Darwin [host] 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
  • Subsystem: Not sure

What steps will reproduce the bug?

Run the following script with node repro.js:

// repro.js
'use strict';

const Repl = require('repl');
const { AsyncLocalStorage } = require('async_hooks');

new AsyncLocalStorage().run({}, async () => {

    Repl.start();

    await new Promise(process.nextTick);
});

The process crashes after the repl prompt > is printed, and a stacktrace from C-land is produced: see the output below.

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

Given the info above it consistently reproduces on node v16.2.0 and v16.3.0, but not on any of the previous versions of node v16.

What is the expected behavior?

The repl should appear, and the rest of the callback passed to run() should execute. The process should not exit until the user exits the repl.

What do you see instead?

This is the output from the reproduction script shown above. The process crashes near-immediately, but you can see that the repl prompt > is output.

> node[90057]: ../src/api/callback.cc:125:void node::InternalCallbackScope::Close(): Assertion `(env_->execution_async_id()) == (0)' failed.
 1: 0x106e127e5 node::Abort() (.cold.1) [/path/to/node]
 2: 0x105ac5b39 node::Abort() [/path/to/node]
 3: 0x105ac59a1 node::Assert(node::AssertionInfo const&) [/path/to/node]
 4: 0x1059f5cdd node::InternalCallbackScope::Close() [/path/to/node]
 5: 0x1059f55de node::InternalCallbackScope::~InternalCallbackScope() [/path/to/node]
 6: 0x105b331db node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task> >) [/path/to/node]
 7: 0x105b31ca7 node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/path/to/node]
 8: 0x1064bec03 uv__async_io [/path/to/node]
 9: 0x1064d287c uv__io_poll [/path/to/node]
10: 0x1064bf171 uv_run [/path/to/node]
11: 0x1059f6ea4 node::SpinEventLoop(node::Environment*) [/path/to/node]
12: 0x105b07414 node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/path/to/node]
13: 0x105a9397d node::Start(int, char**) [/path/to/node]
14: 0x7fff793ca3d5 start [/usr/lib/system/libdyld.dylib]
15: 0x2 
[1]    90057 abort      node repro.js

Additional information

This was originally observed when using hpal-debug's repl, which is run under async local storage. I think that's about it, but happy to provide any more information!

@Lxxyx Lxxyx added async_hooks Issues and PRs related to the async hooks subsystem. confirmed-bug Issues with confirmed bugs. labels Jun 5, 2021
@Lxxyx
Copy link
Member

Lxxyx commented Jun 5, 2021

Can be reproduced on master

@targos
Copy link
Member

targos commented Jun 5, 2021

@nodejs/async_hooks

@Flarna
Copy link
Member

Flarna commented Jun 5, 2021

I'm quite sure that #38912 fixes this.

@targos
Copy link
Member

targos commented Jun 6, 2021

I confirm it is fixed by #38912

@targos targos closed this as completed Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async_hooks Issues and PRs related to the async hooks subsystem. confirmed-bug Issues with confirmed bugs.
Projects
None yet
Development

No branches or pull requests

4 participants