Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 740
fstab Avatar asked Dec 05 '14 13:12

fstab


People also ask

What is node segmentation fault?

wikipedia.org/wiki/Segmentation_fault. In practice, a segfault occurs when your program breaks some fundamental rule set by the operating system. In that case, the operating system sends your process a signal (SIGSEGV on Mac & Linux, STATUS_ACCESS_VIOLATION on Windows), and typically the process shuts down immediately.

Why am I getting a segmentation fault?

A segmentation fault (aka segfault) is a common condition that causes programs to crash; they are often associated with a file named core . Segfaults are caused by a program trying to read or write an illegal memory location.

What causes SIGSEGV?

SIGSEGV is triggered by the operating system, which detects that a process is carrying out a memory violation, and may terminate it as a result. SIGABRT (signal abort) is a signal triggered by a process itself.

Is it possible to hit segfaults in Node JS?

Unfortunately, there are a few cases where you can still hit segfaults in Node: When you use native addons (either directly, or because one of your dependencies uses them), so you're effectively running your own native code as part of your application.

What is a segmentation fault in Linux?

A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system).

How do I fix node not working on my project?

Use this command to check if you have segmentation faults. If you do, clean the npm cache this way. Then try rebuilding your project. If it doesn't work try to uninstall node completely then put it back. You may need to re-run the steps above after reinstalling node and npm.


1 Answers

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.

like image 84
mscdex Avatar answered Sep 20 '22 16:09

mscdex