什么会导致程序异常终止?

发布于 2024-08-15 10:55:20 字数 294 浏览 1 评论 0原文

MFC 应用程序(使用 SQLite3.dll 进行数据库访问,以及其他 DLL 来访问硬件)异常终止。没有特定的终止顺序:( 我的应用程序是

  1. 单线程应用程序
  2. 使用异常处理
  3. 使用超过 6 个 DLL 来访问不同的硬件
  4. 在 WinXP SP2 上运行

最初我认为这可能是因为 Stack Overflow,后来我发现不是。有人能告诉我程序异常终止的一般原因是什么吗?如果有人遇到过类似的问题或者有任何提示或线索,请传递。

提前致谢

MFC application (uses SQLite3.dll for DB access, along with other DLLs for accessing hardware) terminates abnormally. There is no particular sequence of termination :(
My application is a

  1. Single threaded Application
  2. Uses exception handling
  3. Uses more than 6 DLLs to access different hardwares
  4. Runs on WinXP SP2

Initially i thought it might be because of Stack Overflow, later i discovered its not. Can someone tell me what are all the general causes for an abnormal program termination? If someone has come across similar problems or has any hints or clues, please pass them on.

Thanks in Advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仙女 2024-08-22 10:55:20

一般来说,崩溃的一般原因是当您执行以下操作时:

  • 读取不属于您的内存
  • 写入不属于您的内存
  • 除以零
  • 在中断内执行不应
  • free() 的操作不止一次指针

也可能:

  • 有一个未处理的异常
  • 在您的 MFC 中发现了一个错误
  • 您的 >6 硬件访问 DLL 之一正在执行上述任一操作
  • 您遇到了某种硬件故障

也许您将错误的缓冲区传递给硬件 DLL 之一,或者忘记锁定某些内存,或者甚至可能在 DLL 及其标头之间存在版本不匹配。

有很多选择:P

Generally speaking, the general causes of crashes are when you:

  • read memory that isn't yours
  • write memory that isn't yours
  • divide by zero
  • do something inside an interrupt that you shouldn't
  • free() a pointer more than once

Possibly also:

  • have an unhanded exception
  • found a bug in your MFC
  • one of your >6 hardware-access DLLs is doing any of the above
  • You are encountering some kind of hardware fault

Maybe you're passing a bad buffer to one of your hardware DLLs, or are forgetting to lock some memory, or you could even have a version mismatch between the DLLs and their headers.

There are so many choices :P

黑寡妇 2024-08-22 10:55:20

由于这是一个运行时问题,我建议您将调试语句发送到日志文件。包括函数名称,也许还有时间戳。写入文件后始终刷新输出缓冲区,因为这提供了在异常发生之前将最后一行写入文件的更好可能性。

Since this is a run-time issue, I suggest you send debug statements to a log file. Include the function name and perhaps a timestamp. Always flush the output buffer after writing to the file, as this provides better probability that the last line was written to the file before the exception occurs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文