linux - [Solved-4 Solutions] How to generate a core dump in Linux when a process gets a segmentation fault - ubuntu - red hat - debian - linux server - linux pc
Linux - Problem :
How to generate a core dump in Linux when a process gets a segmentation fault ?
Linux - Solution 1:
If you are using bash, then the ulimit command controls several settings relating to program execution, such as whether you should dump core. If you type
You can specify a size such as 52M instead of unlimited if you want, but in practice this shouldn't be necessary since the size of core files will probably never be an issue for you.
In tcsh, you'd type
Linux - Solution 2:
if gcore is not available on your system then
Don't use kill -SEGV as that will often invoke a signal handler making it harder to diagnose the stuck process
Linux - Solution 3:
This program is a demonstration of how to trap a segmentation fault and shells out to a debugger (this is the original code used under AIX) and prints the stack trace up to the point of a segmentation fault. You will need to change the sprintf variable to use gdb in the case of Linux.
Linux - Solution 4:
There are more things that may influence the generation of a core dump.
- The directory for the dump must be writable. By default this is the current directory of the process, but that may be changed by setting /proc/sys/kernel/core_pattern.
- In some conditions, the kernel value in /proc/sys/fs/suid_dumpable may prevent the core to be generated.