如何减少C++的崩溃程序
我有一个用C++实现的大型软件,由VC10 SP1构建。源代码行数超过 1500 万行。它交付给 Windows 平台,包括 win32 和 x64。从崩溃报告来看,平均崩溃时间仅为 40 分钟左右。
我想尽最大努力减少崩溃并延长平均崩溃时间。有人可以分享一下您在实践中所做的事情或者有什么建议吗?任何评论表示赞赏。
谢谢,
杰弗里
I have a big software implemented by C++, built by VC10 SP1. There are more than 15 millions of source code lines. It is delivered to Windows platform, both win32 and x64. From the crash reports, the mean time to crash is only about 40 minutes.
I want to try the best to reduce the crash and extend the mean time to crash. Can somebody share what you have done in practice or is there any suggestion? Any comment is appreciated.
Thanks,
Jeffrey
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这称为调试,或寻找错误的艺术。
提高软件质量的方法有很多。
在设计阶段:
早期阶段的
全部可以在检测代码上运行(例如,激活 STL 调试、使用特定的调试内存分配器、连接监视工具/调试器)。
注意:如果应用程序位于多个组件中,单元/模糊测试更容易应用,因为目标是测试尽可能小的单元。
注意:不要忘记扩展测试套件当您实现新功能或修复错误以防止回归时。
生命期间:
这取决于你培养品质。
仅供参考:我使用的软件每天 24 小时运行,当我们每周发生一两次崩溃时,我们认为我们搞砸了; 45分钟绝对是错误的。
This is called debugging, or the Art of Hunting Bugs.
There are many ways to improve Software Quality.
During the Design Phase:
During the Early Life:
The whole lot can be run on instrumented code (for example, with STL Debugging activated, with specific debugging memory allocators, with monitoring tools/debuggers hooked up).
Note: Unit/Fuzzy Testing are more easily applicable if the application is in multiple components, as the goal is to test as small units as possible.
Note: do not forget to extend the test suite when you implement new functionalities or fix bugs to prevent regression.
During the Life:
It's up to you to foster quality.
FYI: the software I work on runs 24h/7d and when we have a crash once or twice a week, we consider we screwed up; 45min is definitely wrong.
“延长平均崩溃时间”?如何修复代码以使其不会崩溃?巨魔问题?
如果没有,听起来像是内存泄漏。通过内存分析器运行它: http://en.wikipedia.org/wiki/ List_of_performance_analysis_tools#C_and_C.2B.2B
"Extend mean time to crash"? How about fixing the code such that it doesn't crash? Troll question?
If not, sounds like a memory leak. Run it through a memory profiler: http://en.wikipedia.org/wiki/List_of_performance_analysis_tools#C_and_C.2B.2B
一些建议(在明显的调试旁边):
Some suggestions (next to the obvious debugging):
您需要调试源。为了分析它,您可以在源代码中放置断点来分析问题点。
但只有当您专注于代码库中的特定问题领域时,它才会对您有所帮助。为此,您可以对代码中的各个模块执行测试以找到有问题的区域。
看到你的程序在大约 40 分钟内失败,这似乎是内存泄漏的问题。
当您使用VC时,VS提供了一个很好的机制来检测并隔离内存泄漏。
您的代码还可能存在与分配数组然后访问不访问该数组的元素相关的错误。或者代码可能在某个地方向数组添加元素,而不是替换旧的条目,而是继续添加新的条目。
You need to debug the source. For analyzing it, you can put Breakpoints in your source code to analyze the point of problem.
But it is going to help you only when you have zeroed on to a specific area of problem within your codebase. For that you can perform test on various modules within your code to locate the problematic area.
Seeing that your program fails in around 40 minutes, it seems to be a problem with memory leak.
As you are using VC, VS provides a good mechanism to detect and isolate memory leaks.
Your code may also have errors related to having allocating an array and then accessing elements that do not access there. Or somewhere the code could have been adding elements to the array and instead of replacing the older entries it keeps on adding newer ones.