Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

linux
coredump

What is a core dump?

Sadia Zubair

Overview

A core dump is a file in a computer’s documented memory when a program or computer crashes. It consists of a recorded state of the working memory of the computer program at a particular point in time, usually when the program crashes.

Note: Core dump is an integral part of diagnosing the cause of the program crash. The data the application was retrieving is in the core dump, along with information about which part of the application was running at the time of the crash.

Causes of a core dump

A process dumps core when the operating system terminates it due to an error in the program. The most usual reason for this is that the program accessed an invalid pointer value.

Contents of the core dump file

The core dump file may contain the following information:

  • Part of the program that was aborted
  • State of the processor
  • Contents in the processor's register
  • Information on memory management
  • Counter and stack pointer of the program
  • Operating system, processor information, and any flags

Example

int main()
{
   char *val;
   val = "Educative";
   *(val+5) = 'h';
   return 0;
}

Explanation

The above code throws an error of core dump. In line 5, the program attempts to write h to a memory location, which is not allocated for this program. Hence, the code results in a segmentation fault.

RELATED TAGS

linux
coredump

CONTRIBUTOR

Sadia Zubair
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring