Segmentation fault (core dumped), commonly used in the processing core file.

Recently doing a debug camera, always a "segmentation fault (core dumped)" to record what common core document processing, as well as some commonly used commands.
1) First, operation errors encountered such mistakes (core dumped)
2) Open the core file instruction
3) run again wrong program
4) with gdb instruction run core document , troubleshooting error
detailed steps are as follows:
1. run the program appears at my error
Here Insert Picture Description2. turn on the switch related to the operation command generated core file, and set the size.
1) Check if the switch turned on to generate a core file (generally no open)

ulimit -a

Here Insert Picture Description
The first row core file size = 0, there is no description open, we need to open the switch and sets the size of the core file.

ulimit -c

The above operation will generally direct output instruction 0, no instructions or open, we need to add value back to set the size of the core files

ulimit -c  unlimited

After the value provided without limitation, sometimes set too small, no core file.
2) address core file generated core file under normal circumstances is to run the program under the file folder, without setting.
Sometimes produce a lot of times core file and do not want to overwrite the old file the new core, we can add the extension in the Save core file, as follows:
buy add under your command on it

 echo "1" > /proc/sys/kernel/core_uses_pid

I sometimes can not find the address of the generated core file, so when sometimes can not find the core file, you can specify an address to try core file, modify the command as follows:

echo "/corefile/core-%e-%p-%t" > /proc/sys/kernel/core_pattern

It is generated in the corefile file.

3. Run your program again, can be found in the program directory to run a core file as follows:
Here Insert Picture Description
this is my generated core file
4. There are several ways to view the core files, I only said what I use.
My code is as follows:

gdb ./darknet core-darknet-2228-1558761667

gdb <program name> <core file name>
The file name can not be auto-completion, we need to copy themselves into it
Here Insert Picture Description
and then you can see where there was his problem, and I'm still learning how to view specific, the follow-up record again.

Guess you like

Origin blog.csdn.net/weixin_42535742/article/details/90545937