Heisenbug:WinApi 程序在某些计算机上崩溃

2022-01-12 00:00:00 debugging winapi crash c++ gdi

请帮忙!我真的束手无策.我的程序是一个小小的个人笔记管理器(谷歌搜索cintanotes").在某些计算机上(当然我不拥有它们),它在启动后因未处理的异常而崩溃.这些计算机没有什么特别之处,只是它们往往具有 AMD CPU.

Please help! I'm really at my wits' end. My program is a little personal notes manager (google for "cintanotes"). On some computers (and of course I own none of them) it crashes with an unhandled exception just after start. Nothing special about these computers could be said, except that they tend to have AMD CPUs.

环境:Windows XP、Visual C++ 2005/2008、原始 WinApi.

Environment: Windows XP, Visual C++ 2005/2008, raw WinApi.

这是关于这个黑森虫"的肯定:

Here is what is certain about this "Heisenbug":

1) 崩溃仅发生在 Release 版本中.

1) The crash happens only in the Release version.

2) 一旦我删除所有与 GDI 相关的内容,崩溃就会消失.

2) The crash goes away as soon as I remove all GDI-related stuff.

3) BoundChecker 没有任何抱怨.

3) BoundChecker has no complains.

4) 编写日志显示崩溃发生在声明局部 int 变量时!怎么可能?内存损坏?

4) Writing a log shows that the crash happens on a declaration of a local int variable! How could that be? Memory corruption?

任何想法将不胜感激!

更新:我已经设法在故障"PC 上调试了该应用程序.结果:

CintaNotes.exe 中 0x0044a26a 处未处理的异常:0xC000001D:非法指令."

"Unhandled exception at 0x0044a26a in CintaNotes.exe: 0xC000001D: Illegal Instruction."

代码中断

0044A26A cvtsi2sd xmm1,dword ptr [esp+14h]

0044A26A cvtsi2sd xmm1,dword ptr [esp+14h]

看来问题出在代码生成/启用增强指令集"编译器选项中.它被设置为/arch:SSE2"并且在不支持 SSE2 的机器上崩溃.我已将此选项设置为未设置",并且该错误消失了.呼!

非常感谢大家的帮助!!

Thank you all very much for help!!

推荐答案

所以配置为DEBUG配置时不会崩溃?与 RELEASE 配置有很多不同之处:1.) 全局变量的初始化2.) 生成的实际机器代码等.

So it doesnnt crash when configuration is DEBUG Configuration? There are many things different than a RELEASE configruation: 1.) Initialization of globals 2.) Actual machine Code generated etc..

所以第一步是找出与调试模式相比,RELEASE 模式下每个参数的确切设置.

So first step is find out what are exact settings for each parameter in the RELEASE mode as compared to the DEBUG mode.

-AD

相关文章