[Careercup] 12.2 Find the Reason of Crash found the cause of the program crash

Source: Internet
Author: User

12.2 You given the source to a application which crashes when it is run. After running it ten times on a debugger, you find it never crashes in the same place. The application is a single threaded, and uses only the C standard library. What programming errors could is causing this crash? How would all you test?

The problem is that there is an application running crash, after debugging 10 times, found in the same place does not crash. This application is single-threaded, only in the C language standard library, ask what program causes this crash, how to detect every reason. Based on the description in the book, let's start by looking at a common cause of a program crash:

1. Random variables. Programs sometimes use random numbers or variables, each running at a different value.

2. Uninitialized variables. The program has uninitialized variables, which may be assigned to any value in some programming languages.

3. Memory leaks. The program sometimes runs out of memory and also includes heap and stack overflow.

4. External dependencies: Programs sometimes rely on other applications, machines or resources. If there is a lot of external dependencies, chances are that the program will crash at some point.

Since the program does not collapse in the same place, it may be associated with a part or scene. For example, it might be nice to have a program open and nothing to move, but it crashes when you read a file or have other actions. Then we'd better use the exclusion method to find out why, turn off all other applications, and carefully track the various resources. If some of the programs can be disabled, then disable, and then run the program on different machines to see if they will encounter the same problem.

In addition we can use some professional tools to help us find the wrong, for example, problem 2, uninitialized variables, there is a special tool to find these variables for us.

[Careercup] 12.2 Find the Reason of Crash found the cause of the program crash

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.