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