Two errors in the main lecture hall of Cloud Nest Foundation

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Introduction

"Hey, paragraph mistake!" I seem to see this sentence behind the programmer's face of the bitter gourd. Segment error for a programmer is a familiar and can not be familiar with the term, for the experienced programmer on the word that is love and hate, Love is: Fortunately, there have been a paragraph of errors, very easy to find the reason (that is, he has several ways to look for the wrong way, has been cooked), hate is: how always a paragraph error (see all want to vomit). And for inexperienced programmers, paragraph error is a hedgehog, you want to eat he simply can not under the mouth, only a distant view and not obscene play Yan. In response to this situation, cloud nest technology in the bottom of the common library module to add a set of autocratic section of the error module, first unplug your thorn, in consideration of how to eat you.

1. What is a paragraph error?

In a word, a segment error means that the memory accessed exceeds the memory space that the system has set for the program, such as accessing a non-existent memory address, accessing a system-protected memory address, accessing a read-only memory address, and so on.

2. Causes of paragraph errors

1> access to a non-existent memory address.

2> access to the system-protected memory address.

3> access to a read-only memory address.

4> stack overflow, and so on other reasons.

3. Section Error Debugging method

The 1> legend of printf Dafa, this seemingly simplest but often most effective way to debug, may be the programmer to use the most debugging methods. But when it comes to big project development and a lot of source code, using printf doesn't quickly locate the problem, and you don't know where to add printf print.

2> using GDB debugging

For novice programmers, GDB still has a large number of people do not use, if you want to use GDB, but also to learn from GDB's commands and operations, 8630.html "> sometimes waste some time."

Intelligent Automatic Detection Section error module of 3> Cloud Nest development

No complex operation, no guessing the pain of the code, only need to call a simple initialization function interface, you can automatically detect the error of the program generated by the location, accurate positioning, all ages.

4. Cloud Nest Technology Intelligent Detection Segment Error module

1> Basic principles:

Print the segment error message to the generated file by capturing the segment error signal generated in the system.

2> signal:

1) Sigquit 2) Sigill 3) SIGABRT 4) SIGFPE 5) SIGSEGV 6) Sigbus 7) Sigsys 8) Sigtrap 9) sigxcpu) Sigxfsz

We see SIGSEGV in which the general array crosses the line or accesses the null pointer to produce this signal. Cloud Nest development of the detection section error module, can be perfect to capture the above listed the generation of error signal, and the generation of error signal line for accurate positioning. Unplug him from the Thorn, for the company's research and development staff to provide great convenience, improve the efficiency of the work. In fact, the paragraph error is not terrible, terrible is not a good debugging section error method. Yun Che just saw this aspect, developed the intelligent detection Segment error module.

5. The development should pay attention to the matter, avoids produces the paragraph error

1, when there is a segment error, you should first think of the definition of the paragraph, from which to consider the cause of the error.

2. When using the pointer, remember to initialize the pointer after defining the pointer, and remember to judge whether it is null when used.

3, when using the array, notice whether the array is initialized, whether the array subscript is out of bounds, whether the array element exists, etc.

4. When accessing variables, notice whether the variable occupies the address space has been released by the program.

5, in the processing of variables, attention to variable format control is reasonable and so on.

Free Application Cloud Nest IPC Address: http://pc.vcnglobal.cn

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.