C-Segment errors and other debugs

Source: Internet
Author: User

This document refers to Http://stackoverflow.com/questions/2179403/how-do-you-read-a-segfault-kernel-log-message and/HTTP www.slideshare.net/noobyahoo/introduction-to-segmentation-fault-handling-5563036

Linux in the case of a segment error, most people will think of core dump, but not necessarily, there are other ways, when the process of such problems, using DMESG view, you will see similar to the following information (the StackOverflow example)

KERNEL:MYAPP[15514]: Segfault at 794EF0 IP 080513b SP 794EF0 error 6 in myapp[8048000+24000]

Such an error, or sometimes see a xxx.so errors, if you see glibc in error, do not suspect is glibc error, because our code error may appear in glibc, such as the call glibc function, This can happen if the address is an illegal address.

The method is very simple, using Addr2line or Objdump, IP is the address of the corresponding code, at is the memory address of Segfault, most of the case, if this is 0 or-1, can help to find the reason, such as your pointer address is NULL or (void *)-1, Most of the situation is sufficient according to IP, error is the wrong reason, and is not analyzed temporarily.

1 dead in the target program

Objdump-dcgls Myappo >>/tmp/debug_message

Then vim/tmp/debug_message, look for IP address 080513b,

May find multiple, some may be debug and other information, without careful study, you can easily see, in the code of the corresponding file and number of lines, if you want to see the code, you may need the code path is correct, OK, so you have to get the error in the code location, basic simple check can find the cause of the error.

2 die in the xxx.so, the error will have XXX.SO[AAA+BBB], AAA is the load address, IP and AAA to do the subtraction of the 16 number is offset, and the above practice, OK

3 die in glibc, this can be troublesome, because even if you find the corresponding function, but there are too many places to call in the code, not easy to locate, and temporarily still uncertain.

4 using Addr2line addr2line-f-e MyApp 080513b

5 If the binary file is strip, this method fails, you can recompile the corresponding version of the code, retain the necessary information, and then use the newly generated file to find the address.

6 for kernel code can also use a similar method, as long as the corresponding IP address, to get a binary file without strip OK.

C-Segment errors and other debugs

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.