Search This Blog

Sunday, January 6, 2013

Getting more info on segmentation fault

Hi all,
This is just a very small post which might be useful to you.. Mostly when you develop some codes, especially in some native languages like C, C++, sometimes you face some error "Segmentation Fault (Core Dumped)". This post is all about how we get more info on this when you are working on Linux.

Has anyone wondered what is that called "Core Dumped" that appears after segmentation fault ? and where is it dumped ? :) It is not dumped anywhere unless you enable it.. So we shall learn how to enable it....

Step 1: Change your current directory to temp

# cd /tmp

Step 2: Enable core dump

# ulimit -c unlimited

Step 3: Execute your program in which you face segmentation fault

For example,

# /opt/myprogram.out

It produces,

Segmentation Fault (core dumped)

Thats it, now you have core dumped in /tmp/core file. You can open it with your favorite editor (I prefer vi editor, as other editors crash mostly when you open such binaries).

Note:
The file is a binary and it has more junk info.. parse through the file to check some errors somewhere..

No comments:

Post a Comment