Repository navigation
Assertion `(env_->execution_async_id()) == (0)' failed #38155
Description
Activity
@addaleax is this supposed to be possible?
@ronag no, hence the assertion
- addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.
on Apr 9, 2021 - addedasync_hooksIssues and PRs related to the async hooks subsystem.Issues and PRs related to the async hooks subsystem.
on Apr 9, 2021 @ronag Do you have a reproducer? I doubt this happens just by calling
node --version:o)Sorry. Happened while debugging another issue and haven’t happened since.
@Flarna @addaleax If you clone this https://github.com/nodejs/undici/tree/native-assert and run
tap test/tls-session-reuse.jsyou should get the assertion.I did a fast try but failed to reproduce the crash. Should it happen always or only every now and then?
Any dependecy to nodejs version or OS?Node v15.5.1, OSX 11.2.3.
It should happen every time.
Stack trace on my mac:
/Users/targos/git/nodejs/node/out/Debug/node[16113]: ../../src/api/callback.cc:125:void node::InternalCallbackScope::Close(): Assertion `(env_->execution_async_id()) == (0)' failed. 1: 0x1024e3b38 node::DumpBacktrace(__sFILE*) [/Users/targos/git/nodejs/node/out/Debug/node] 2: 0x10262bf90 node::Abort() [/Users/targos/git/nodejs/node/out/Debug/node] 3: 0x10262bc18 node::AppendExceptionLine(node::Environment*, v8::Local<v8::Value>, v8::Local<v8::Message>, node::ErrorHandlingMode) [/Users/targos/git/nodejs/node/out/Debug/node] 4: 0x1024627fc node::InternalCallbackScope::Close() [/Users/targos/git/nodejs/node/out/Debug/node] 5: 0x1024625b4 node::InternalCallbackScope::~InternalCallbackScope() [/Users/targos/git/nodejs/node/out/Debug/node] 6: 0x102461dcc node::InternalCallbackScope::~InternalCallbackScope() [/Users/targos/git/nodejs/node/out/Debug/node] 7: 0x102513d70 node::Environment::RunAndClearNativeImmediates(bool) [/Users/targos/git/nodejs/node/out/Debug/node] 8: 0x10251352c node::Environment::CheckImmediate(uv_check_s*) [/Users/targos/git/nodejs/node/out/Debug/node] 9: 0x10365256c uv__run_check [/Users/targos/git/nodejs/node/out/Debug/node] 10: 0x103647f60 uv_run [/Users/targos/git/nodejs/node/out/Debug/node] 11: 0x10246791c node::SpinEventLoop(node::Environment*) [/Users/targos/git/nodejs/node/out/Debug/node] 12: 0x1026c3594 node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/Users/targos/git/nodejs/node/out/Debug/node] 13: 0x1025a0724 node::Start(int, char**) [/Users/targos/git/nodejs/node/out/Debug/node] 14: 0x103e4f3d4 main [/Users/targos/git/nodejs/node/out/Debug/node] 15: 0x195131f34 start [/usr/lib/system/libdyld.dylib]Lines 122 to 127 in e46c680
// Make sure the stack unwound properly. If there are nested MakeCallback's // then it should return early and not reach this code. if (env_->async_hooks()->fields()[AsyncHooks::kTotals]) { CHECK_EQ(env_->execution_async_id(), 0); CHECK_EQ(env_->trigger_async_id(), 0); } I think it's that assert?
Till now I failed to reproduce on windows or WSL. Found no time yet to test on linux. I have no access to a mac.
Tried on linux and can't reproduce there with 15.14.0. The test just fails with JS exceptions:
FAIL test/tls-session-reuse.js 5 failed of 5 142.07ms ✖ Cannot convert undefined or null to object ✖ should be equal ✖ Cannot read property 'toString' of undefined ✖ Cannot read property 'reuseSessions' of undefined ✖ connect ECONNREFUSED 127.0.0.1:33543Either I'm doing something wrong here or it effects only MacOs.
12 remaining items
It's easy to reproduce but as said above I doubt it's a nodejs issue.
Or was there any change regarding the testsetup to no longer use
async-hook-domain?I doubt it's a nodejs issue.
An assertion should never happen when running user code. IMHO it's a node issue.
@ronag That's true only for user code that doesn't touch internal APIs. For example, it's not a node issue if someone triggers an assertion by directly calling
process.binding('fs').chmod().
If this assertion is triggered becauseasync-hook-domainhas a bug in its custom implementation ofprocess._fatalException, then it's anasync-hook-domainissueReacted by Robert Nagy@targos Yes. But I'm more referring to @szmarczak's repro.
That repro doesn't crash if I comment out this line:
https://github.com/tapjs/async-hook-domain/blob/master/index.js#L31Reacted by Robert Nagy and Szymon MarczakThat repro doesn't crash if I comment out this line:
https://github.com/tapjs/async-hook-domain/blob/master/index.js#L31Ah, I didn't realize that was relevant there as well.
Does anyone have a solution to this issue? Or is there is anything we could do to fix this issue?
Is it something that https://github.com/tapjs/async-hook-domain should fix or is it on the Node.js side?I can't reproduce the issue locally on my Ubuntu 21.10, but somehow the issue appears when using
ubuntu-lateston the GitHub Actions (usingtaptest runner), usingmacos-latestinstead and there is no issue.
Is this issue related to the Linux kernel or some low-level stuff?
Does anyone have an explanation of why there is no problem on my local computer with Ubuntu 21.10, but there is this issue on GitHub Actions usingubuntu-latest, solatestshould be 20.04 I guess.has there been found a solution to this issue? I'm experiencing the same problem and have changed node version several times, nothing helps :(
I have a situation where this issue does occur, but it does not if I use
--inspect-brk.To be more precise, this script starts an express server, among other things, and for some reason it doesn't fail if I manage to attach the debugger before the end of some initialization steps.
So I can either start the process and quickly attach the debugger, or just use
--inspect-brk, which is easier to make sure I can attach before the end of those initializations.Unfortunately I can't share this project because it doesn't belong to me and it is not public.
But I guess this can be a useful workaround for people out there.Heya, I've hit the same problem; I've created a repro here.
@delvedor Thanks for your repo. But again it uses tap which internally uses async-hook-domain which is likely doing something wrong by monkeypatching node internal. See above comments.
Reacted by Tomas Della VedovaSeems latest versions of
async-hook-domainno longer monkey pathprocess._fatalException(see here).Is this problem still occurring anywhere with latest version of
async-hook-domainused?@Flarna i haven't seen the issue lately, no.
closing as it seem problem is solved by latest version of
async-hook-domain. Feel free to reopen or create a new issue if it is reproducible without 3rd party dependencies.Reacted by Théo LUDWIG
I managed to trigger an assertion.