Sunday, July 22, 2012

Core dump file not found

Has it ever occurred to you that you ran a program, it aborted saying 'core dumped' , but then when you go around looking for the core dump file, you cant find it anywhere? 0-o

Well it happened to me today. I tried finding the 'core' file in each of the possible directories - the pwd, the executable directory, all the directories in the $PATH variable.

To my dismay, none of them had the core file in them.

After some google search, I found that there may be cases where the core file is not created to save space. (Core files are usually large ~1GB ).

I also found out that in my system (Ubuntu 12.04 LTS), the default size allocated to core files is 0.

This can be found using the command

ulimit -a


 If you see ulimit -c 0 , that means 0 blocks have been allocated to core dump file , and hence core dump file is not formed.

To enable the core dump, we can do the following :


ulimit -c unlimited

This increases the coredump size to unlimited. Now, try executing the code that caused Aborted (Core dump formed).

and check the pwd (present working directory) for 'core'  file. You will notice that core file is very large. And hence I feel that in Ubuntu, as  a protective measure, the core dump file has been allocated 0 blocks by default.

NExT up -> tips on how to use objdump for debugging through core file. :)

No comments:

Post a Comment