[Master Answer Logo]
Question

How to handle core dump in c program?

Answer

Contrary to what its name might suggest, a page fault is not necessarily a fatal error. In any operating system that utilises virtual memory to increase the amount of memory available to programs, page faults are a common and necessary occurrence. The general protection fault, or the less common "invalid page fault," found on computers running a Microsoft Windows operating system, are actually generated by the exception handling code in the operating system's page fault handler. When a page fault occurs that would cause Windows to page in memory that the currently-running program does not have permissions to access, such as accessing memory that properly belongs to another process, the system will generate a "general protection fault." If a page fault occurs that references a non-existent memory page, such as trying to read a null pointer, the system may alternately generate an "invalid page fault." (Recent versions of Windows replace both these and other hardware-generated fault errors with a single, less technical error simply stating that "this program must close", but the underlying causes are the same). UNIX and UNIX-like operating systems will handle these conditions by delivering signals, such as SIGSEGV ("segmentation violation"), to the offending process. In all of these cases, the fatal error is ultimately the fault of poorly behaving software, and not of the hardware.

— Source: Wikipedia (www.wikipedia.org)