开发者

Core Dump & Segmentation Fault

I want to know the exact difference between segmentation fault and core dump. I agree that these are operating system dependent and, of course, arise due to the memory 开发者_StackOverflow社区mismanagement. But please come up with some generic approaches which needs to be followed to prevent these?

Sachin Chourasiya


A core file is a memory image of a crashed process. With a debugger you can find out the possible causes of the crash. If you don't know what to do with a core file (except rm core), you can request not to generate them with limit coredumpsize 0.

A segmentation fault is one of the manifestations of a process crash. Usually it arises when the program tries to access memory that it shouldn't.

There are amny causes of segmentation fault. here is a non-exhaustive list:

  • access to data through an uninitialized pointer
  • access to malloc'ed memory which has been free'd
  • access to array elements beyond the array size
  • ...

Tools exist for detecting such memory bad access. purify or lint are example of these.


A segmentation fault are the result of invalid memory access and cause a SIGINT signal that usually causes the application to terminate.

A core dump is a file that is usually written when an application crashes after e.g. a segmentation fault to that the developer can analyze the state of the application at the time of the crash.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜