What is a "segment error" with Core and GDB queries under Core Dump Linux

Source: Internet
Author: User

What is a "segment error" with Core and GDB queries under Core Dump Linux

Http://blog.chinaunix.net/uid-26833883-id-3193279.html

Sometimes when we are in a C code, due to an illegal memory operation, in the process of running the program, there is a "segment error."

Oh, this kind of problem I think a lot of people will often meet. Encounter this problem is very silent, just hint "paragraph error", and then nothing, if we blindly to see the code to find too painful, because we all believe that their code is no problem, the reality is reality. Here's a way to effectively locate a "segment error."

When our program crashes, it is possible for the kernel to map the current memory of the program to the core file, so that the programmer can find out where the program is having problems.

What is core dump?

The core means memory, and dump means to throw it out and heap it out.
Why is there no core file generation?

Sometimes the program is down, but the core file is not generated. The build of the core file is related to the environment settings of your current system, and you can set up a core file with the following statement.
Ulimit-c Unlimited

The core file is generated in the same way as the running program, and the file name is typically core under Ubuntu.

What is a core file

When a program crashes, the stored image of the process is copied in the core file of the current working directory of the process. The core file is simply a memory image (plus debugging information) that is used primarily for debugging.

Let's take a look at how to use the core file to locate us where "segment error" occurs.

-c unlimited# the size of the largest core file, in blocks units. Ulimit–c Unlimited; the size of the resulting core file is not limited. 

Program Run Result:

From the above we can see that the first run the program "segment error" does not appear in the core file, the general Linux operating system default core file size is 0, need to manually set.

Debug Core file

The core file is a binary file and requires a tool to parse the memory image of the program when it crashes.

You can use GDB to debug a core file under Linux.

From the above we can clearly see that our program is in that place error.

Hehe, with this method, I think we can no longer be so afraid of "paragraph error".

What is a "segment error" with Core and GDB queries under Core Dump Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.