-
Notifications
You must be signed in to change notification settings - Fork 225
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
RangeError: Maximum call stack size exceeded #299
Comments
Some clarificationWe had a small discussion about performance, where @nin-jin provided the code similar to the above that uses That code crashes for me, also
The code provided by @nin-jin fails with an error on my Arch Linux notebook both with the official binaries of Node.js 6.3.1 (link above) and the version from Arch Linux packages (also 6.3.1). It's randomish (fails 90% of the times, depends on the |
The stack overflow tests included are known to fail, though the conditions created in the tests don't really mimic real-world applications. The main issue is that v8 seems to have issues with not respecting stack boundaries (see references to SetStackGuard in fibers.cc) and it's something I have never quite been able to work around. Though this actually only comes up in the case when you have runaway recursion-- instead of a thrown RangeError you get a segfault. Support for Arch Linux (specifically musl as opposed to glibc) is somewhat experimental, so issues under extreme circumstances are not surprising. If you run into these issues I'd suggest checking out the soon-to-be-standard async+await keywords, which build upon the existing generator support in v8. The capabilities exposed by both fibers and async+await are pretty much interchangeable so migrating to one or the other shouldn't be much of a challenge. |
But I don't even have |
That's pretty much the same what I told to @nin-jin 😉. |
@ChALkeR you're right, I was confusing Arch and Alpine. Looking at @nin-jin's case a little more closely I understand why it's failing. Calling Future.wait() manually with huge amount of futures isn't really normal. There, we're getting a graceful RangeError because it's recursing too deep. I believe that since all the futures resolve immediately Future.wait() calls them all one after another and it hits the recursion limit. You could rewrite that as follows without any issue: "use strict"
const Future = require('./future');
function test() {
const future = new Future;
setImmediate(() => future.return());
future.wait();
}
Future.task(function() {
const arr = new Array(3000).fill(0);
const a = arr.map(() => Future.task(test));
a.forEach((future) => future.wait());
const b = arr.map(() => Future.task(test));
b.forEach((future) => future.wait());
}).detach(); The I'll see about adding a step to Future.wait() to tune back the recursion so it doesn't run into this. Regard async+await, for new projects I think it's the right choice to use those new language features over Fibers. |
Why theare are no errors on Windows10@64?
Epic fail. See comparison: https://github.com/nin-jin/async-js |
@laverdet But I believe this specific issue in fact could be fixed on the
Your comparison is inaccurate, you measure a single function call of a few ms. That dousn't show anything. Also, you are missing that native async/await would be shipped relatively soon. Let's not have this discussion here, though. |
@ChALkeR, not only performance i was compared, you known. |
@ChALkeR complains on subject and segfault in
test/stack-overflow2.js
.Environment
Linux yoga 4.6.3-1-ARCH #1 SMP PREEMPT Fri Jun 24 21:19:13 CEST 2016 x86_64 GNU/Linux
Node.js — 6.3.1
Code
Run
The text was updated successfully, but these errors were encountered: