Why are core dump files generated?

前端 未结 7 559
鱼传尺愫
鱼传尺愫 2020-12-05 11:10

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.*.

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 11:34

    Core dumps are generated when the process receives certain signals, such as SIGSEGV, which the kernels sends it when it accesses memory outside its address space. Typically that happens because of errors in how pointers are used. That means there's a bug in the program.

    The core dump is useful for finding the bug. It is an image of the the process's memory at the time of the problem, so a debugger such as gdb can be used to see what the program was doing then. The debugger can even access (sometimes) the values of variables in the program.

    You can prevent core dumps from happening using the ulimit command.

提交回复
热议问题