Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are core dump files generated?

Tags:

linux

coredump

Sometimes when I run my code, a core dump file is generated when I terminate the program by Ctrl+\. The file name is of the form core.*. The program is not terminating abruptly, and there is no segmentation fault. I believe it is SIGQUIT and not SIGABRT or SIGSEGV. If I try Ctrl+C, or Ctrl+Z, then it is not generated.

Can anyone tell why it is generated only when Ctrl+\ is pressed? How can I avoid this core dump file from being generated? Is there any use for the core dumped file?

like image 381
Chaithra Avatar asked Apr 22 '09 05:04

Chaithra


2 Answers

A process dumps core when it is terminated by the operating system due to a fault in the program. The most typical reason this occurs is because the program accessed an invalid pointer value. Given that you have a sporadic dump, it's likely that you are using an uninitialized pointer.

Can you post the code that is causing the fault? Other than vague generalizations it's hard to guess what's wrong without actually seeing code.

As for what a core dump actually is, check out this Wikipedia article:

  • http://en.wikipedia.org/wiki/Core_dump
like image 195
JaredPar Avatar answered Nov 15 '22 16:11

JaredPar


As said by others before the core dump is the result of a fault in the program.

You can configure if a core dump is to be generated with the ulimit command. Entering

ulimit -c 0

disables core file generation in the active shell.

If the program that generated the core was built with symbol information you can do a post mortem debugging session like this:

gdb <pathto/executable> --core <corefilename>
like image 20
lothar Avatar answered Nov 15 '22 18:11

lothar