调试的崩溃10次在不同的地方的程序 [英] Debugging a program that crashes 10 times in different places
问题描述
您给出的源是在运行时崩溃的应用程序。在调试器中运行10次后,你会发现它永远不会崩溃在同一个地方。该应用程序是单线程的,并且仅使用C标准库。什么编程错误可能会导致这会崩溃吗?你会如何测试每一个?
You are given the source to an application which is crashing during run time. After running it 10 times in a debugger, you find it never crashes in the same place. The application is single threaded, and uses only the C standard library. What programming errors could be causing this crash? How would you test each one?
推荐答案
您code可以调用与不确定的行为在任何C标准,包括(但不限于):
Your code could be invoking anything with undefined behaviour in the C standard, including (but not limited to):
- 未初始化的变量,但尝试使用它的值。
- 取消对NULL指针。
- 读取或写入过去的数组的末尾。
- 定义与下划线和大写字母或其他下划线开头的preprocessor宏。
名单很长,但附件J.2在C规范提供的未定义行为简明列表。
The list is long, but Annex J.2 in the C specification provides a concise list of undefined behaviour.
这篇关于调试的崩溃10次在不同的地方的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!