Repository navigation
Repl Crashes in infinite Async recursion #40502
Copy link
Copy link
Closed
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.linuxIssues and PRs related to the Linux platform.Issues and PRs related to the Linux platform.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
Description
Activity
@nodejs/repl
- addedreplIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
on Oct 18, 2021 - addedlinuxIssues and PRs related to the Linux platform.Issues and PRs related to the Linux platform.
on Oct 18, 2021 - addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Nov 29, 2021 Pressing enter crashes the REPL with newer versions. This is likely an issue due to top level away support?
When building on master it is crashing without pressing enter as well @BridgeAR .
On further deep-dive it seems TCO (Tail call optimisation) is not kicking in. To verify this hypothesis i have written a simple script
'use strict'; const fn = (a) => { a(a); } fn(fn);
On executing the above script it is always erroring out with
StackOverflow❯ ./node crash.js /Users/yashLadha/opensource/node/crash.js:4 a(a); ^ RangeError: Maximum call stack size exceeded .... Node.js v18.0.0-preV8 doesn't implement TCO.
Reacted by Anna HenningsenThen isn't the expected behaviour in the issue template seems wrong?
One more thing if you change the snippet just slightly.
(async (a) => process.nextTick(() => a(a)))(async (a) => process.nextTick(() => a(a)))
It won't crash the repl as stack won't exceed but might end up in the following error:
> RangeError: Map maximum size exceeded at Map.set (<anonymous>) at AsyncHook.init (node:domain:76:15) at emitInitNative (node:internal/async_hooks:201:43) at emitInitScript (node:internal/async_hooks:506:3) at promiseInitHook (node:internal/async_hooks:321:3) at promiseInitHookWithDestroyTracking (node:internal/async_hooks:325:3) at REPL1:1:45 at REPL1:1:81 at processTicksAndRejections (node:internal/process/task_queues:77:11)```
I can't reproduce in the latest version of Node.js
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.linuxIssues and PRs related to the Linux platform.Issues and PRs related to the Linux platform.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
Version
v16.1.0
Platform
Linux linx-PC 5.8.0-63-generic #71-Ubuntu SMP Tue Jul 13 15:59:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
Repl
What steps will reproduce the bug?
(async (a)=>a(a))(async (a)=>a(a))but don't press returnHow often does it reproduce? Is there a required condition?
100% of the time.
What is the expected behavior?
The repl should not crash.
What do you see instead?
Additional information
Typing
(a=>a(a))(a=>a(a))doesn't crash and only prints the error after you press enter.