19

I am trying to debug a segmentation fault caused by my C program using gdb. A core dump file is not automatically generated when I run my program,and i have to run the command

ulimit -c unlimited

for a core file to be generated on the next run.

Why is a core dump file not generated automatically and why do I have to run the ulimit command everytime to generate a core file on the next run of my program ?.

The operating system i use is Ubuntu 10.10.

0

4 Answers 4

22

You need to place the command

ulimit -c unlimited

in your environment settings.

If you are using bash as your shell, you need to place the above command in ~/.bashrc

16

You might also want to try to edit /etc/security/limits.conf file instead of adding ulimit -c unlimited to ~/.bashrc.

The limits.conf is the "correct" place where to specify core dump details in most Linux distros.

9

That's because by default your distribution limits core file size to 0 blocks. The ulimit command you mentioned increases that limit to infinity.

I don't know about Ubuntu, but most distros have a file /etc/limits with system defaults for resource limits.

-1

The segmentation fault is due to irrelevant values for path variables. On my system the user is sidd@sidd-Lenovo-G460 and the contents added are as below.

PATH=$PATH:/home/sidd/ns-allinone-2.35/bin:/home/sidd/ns-allinone-2.35/tcl8.5.10/unix:/home/sidd/ns-allinone-2.35/tk8.5.10/unix

LD_LIBRARY_PATH=/home/sidd/ns-allinone-2.35/otcl-1.14:/home/sidd/ns-allinone-2.35/lib

TCL_LIBRARY=/home/sidd/ns-allinone-2.35/tcl8.5.10/library

Please refer this blog post (VERY IMPORTANT).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.