fstab
fstab

Reputation: 5029

node.js and Segmentation fault

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.

Upvotes: 9

Views: 13874

Answers (2)

Flame_Phoenix
Flame_Phoenix

Reputation: 17584

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:

So for now ( with Node.js 8.x ) the best solution is simple to stop using recursive functions.

Upvotes: 2

mscdex
mscdex

Reputation: 106706

There 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.

Upvotes: 2

Related Questions