如何调试仅在应用程序关闭时发生的崩溃?(德尔福) [英] How to debug a crash that only occurs on application shutdown? (Delphi)

查看:24
本文介绍了如何调试仅在应用程序关闭时发生的崩溃?(德尔福)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,经过最近的一些更改,我们发现我们最古老的应用程序之一有时会在关机时崩溃.这表现为运行时错误 216"消息或来自 Windows 错误报告的应用程序已停止工作的消息.应用程序已经在每一次发出 OutputDebugString 消息,并且 AFAICT 我们自己的所有代码都被正确执行到完成.所有的析构函数都像所有终结部分和类析构函数一样被调用,它们都没有引发任何异常.

So, after some recent changes we discovered that one of our oldest applications is sometimes crashing on shutdown. This manifests itself either in the form of "Runtime error 216" messages or in a message from Windows Error Reporting that the application has stopped working. The application is already emitting OutputDebugString-messages at every turn and AFAICT all of our own code gets executed correctly to completion. All destructors are called as are all finalization sections and class destructors, none of which are raising any exceptions.

此外,madExcept 和 FastMM4 的完全调试模式似乎都没有什么可抱怨的(尽管这可能是一个错误的结论,因为崩溃可能在这些组件自己的最终代码运行之前发生).

Also, neither madExcept nor FastMM4's Full Debug Mode seem to have anything to complain about (though that might be a false conclusion because the crash might happen even before those components' own finalization code runs).

那么,你会怎么做?你会从哪里开始?

So, what would you do? Where would you start?

这个问题应该更多地是关于这类问题的一般方法,而不是关于我目前面临的具体实例,所以我故意省略了细节.随意询问您是否认为它们可能与调试方法的选择有关,我稍后会添加它们.

推荐答案

运行时错误 216 表示您有 Av(访问冲突)并且 SysUtils 已经停止将这些错误转换为异常.

A runtime error 216 means that you have an Av (access violation) and SysUtils has already stopped translating those errors to exceptions.

第一次尝试:使用调试 DCU 构建并查看引发错误的单位系统,在那里设置断点.希望您可以在调试器中捕获它并从那里开始工作.

First try: Build with debug DCU's and look in the unit system where the error is raised, set a breakpoint there. hopefully you can catch it in the debugger and work from there.

您可能有内存错误(悬空指针、空引用等)在已完成的单元中使用 s 字符串常量,最好的技巧是在 sysutils 完成后检查完成情况.您可以通过构建 WITH 调试 dcu,在 sysutils 中将断点设置为最终确定,然后开始逐步执​​行代码,直到发生错误.

You probably have a memory bug (dangling pointer, null reference etc etc use of s string constant in an already finalized unit) and the best trick is to check the finalizations after sysutils is finalized. You can do this by building WITH debug dcu's, setting the break point to the finalization in sysutils and start stepping through the code until the error occurs.

这篇关于如何调试仅在应用程序关闭时发生的崩溃?(德尔福)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆