is it possible to inspect the javascript stack trace when node.js
goes in Segmentation fault?
The current situation is the following: I am running a script which has a few nested async.eachSeries
, which caused for some weird reason a RangeError: Maximum call stack size exceeded
. Hence, I have increased the stack size via node --stack-size=1000000
and I am left with the Segmentation fault.
Here is the source code of the script: .html
Update
I also tried segfault-handler
, but for some inscrutable reason it is not catching my segfault.
is it possible to inspect the javascript stack trace when node.js
goes in Segmentation fault?
The current situation is the following: I am running a script which has a few nested async.eachSeries
, which caused for some weird reason a RangeError: Maximum call stack size exceeded
. Hence, I have increased the stack size via node --stack-size=1000000
and I am left with the Segmentation fault.
Here is the source code of the script: http://nopaste.info/ca0c118591.html
Update
I also tried segfault-handler
, but for some inscrutable reason it is not catching my segfault.
- You might consider posting your code. – mscdex Commented Dec 5, 2014 at 13:35
- here is the source code of the script: nopaste.info/ca0c118591.html – fstab Commented Dec 5, 2014 at 13:45
- Which version of node? – zhon Commented Apr 5, 2015 at 13:29
- @zhon: ha, this is an old post. I think the version that was the latest at the 5th of december 2014 – fstab Commented Apr 5, 2015 at 21:21
-
Try rewriting your task so that it calls its callback asynchronously, i.e. instead of
doTask(task, done);
writedoTask(task, function(err, res) { setImmediate(done, err, res); });
. – David Knipe Commented Aug 4, 2016 at 10:34
2 Answers
Reset to default 2There is the segfault-handler
module which catches segfaults on non-Windows platforms and generates a stack trace. But if you're getting a RangeError
, that's not a segfault.
This likely means you have recursivety somewhere in your code. Since V8 removed support for TCO (Tail Call Optimization) the call size will grow until it explodes.
Using --stack_size
would seem like a natural solution, but it doesn't actually increase the stack size, it is tells V8 to assume there is a bigger stack size when in reality this is controlled by the OS.
Sources:
- https://github./nodejs/node-v0.x-archive/issues/5669
- https://github./nodejs/node/issues/6360
- Node.js tail-call optimization: possible or not?
So for now ( with Node.js 8.x ) the best solution is simple to stop using recursive functions.