windows 调试可怕的“应用程序初始化失败”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2214465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Debugging the dreaded 'Application has failed to initialize' error
提问by Chris Dodd
I occasionally run into this error when trying run an executable I've built on windows, but I have no idea what causes it or how to fix it. With the normal MSVC debugger, it just pops up a dialog and exits with no chance to do anything or look at anything. I've managed to at least catch something and get a stack trace with the Microsoft console debugger, but I have no idea what to look at from here. It seems to be failing oddly within ntdll.dll before ever getting to main function of my program or running any of my code.
在尝试运行我在 Windows 上构建的可执行文件时,我偶尔会遇到此错误,但我不知道是什么原因导致它或如何修复它。使用普通的 MSVC 调试器,它只是弹出一个对话框并退出,没有机会做任何事情或查看任何内容。我已经设法至少捕捉到一些东西并使用 Microsoft 控制台调试器获得堆栈跟踪,但我不知道从这里看什么。在进入我的程序的主要功能或运行我的任何代码之前,它似乎在 ntdll.dll 中奇怪地失败了。
C:\> cdb bugrepro
Microsoft (R) Windows Debugger Version 6.11.0001.404 X86
Copyright (c) Microsoft Corporation. All rights reserved.
CommandLine: bugrepro.exe
Symbol search path is: C:\SYMBOLS
Executable search path is:
ModLoad: 00400000 00447000 bugrepro.exe
ModLoad: 7c900000 7c9af000 ntdll.dll
ModLoad: 7c800000 7c8f6000 C:\WINDOWS\system32\kernel32.dll
ModLoad: 10000000 1002a000 glut32.dll
ModLoad: 5ed00000 5edcc000 C:\WINDOWS\system32\OPENGL32.dll
ModLoad: 77c10000 77c68000 C:\WINDOWS\system32\msvcrt.dll
ModLoad: 77dd0000 77e6b000 C:\WINDOWS\system32\ADVAPI32.dll
ModLoad: 77e70000 77f02000 C:\WINDOWS\system32\RPCRT4.dll
ModLoad: 77fe0000 77ff1000 C:\WINDOWS\system32\Secur32.dll
ModLoad: 77f10000 77f59000 C:\WINDOWS\system32\GDI32.dll
ModLoad: 7e410000 7e4a1000 C:\WINDOWS\system32\USER32.dll
ModLoad: 68b20000 68b40000 C:\WINDOWS\system32\GLU32.dll
ModLoad: 73760000 737ab000 C:\WINDOWS\system32\DDRAW.dll
ModLoad: 73bc0000 73bc6000 C:\WINDOWS\system32\DCIMAN32.dll
ModLoad: 76b40000 76b6d000 C:\WINDOWS\system32\WINMM.dll
(64c.7b4): Unknown exception - code c0000022 (first chance)
(64c.7b4): Unknown exception - code c0000022 (!!! second chance !!!)
eax=0012fc54 ebx=00000000 ecx=0012fc80 edx=7c90e4f4 esi=7ffd8000
edi=c0000022
eip=7c96478e esp=0012fc54 ebp=0012fca4 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
ntdll!RtlRaiseStatus+0x26:
7c96478e c9 leave
0:000> ~k
ChildEBP RetAddr
0012fca4 7c93f14e ntdll!RtlRaiseStatus+0x26
0012fd1c 7c90e437 ntdll!_LdrpInitialize+0x241
00000000 00000000 ntdll!KiUserApcDispatcher+0x7
0:000>
Anyone have any suggestions of where to go from here in debugging this?
任何人都对从这里开始调试这个有什么建议吗?
回答by Bahbar
Following up on Moron's answer, You should run Process Monitor.
跟进白痴的回答,您应该运行Process Monitor。
This tool will tell you exactly what your process does, and which files it tried (and likely at least for one failed) to load, and what the errors are.
这个工具会告诉你你的进程做了什么,它尝试(并且可能至少有一个失败)加载了哪些文件,以及错误是什么。
It does more than this, and for anyprocess troubleshooting, it's an amazing time-saver.
它的作用不止于此,而且对于任何过程故障排除,它都是惊人的节省时间。
回答by Matteo Italia
Usually the "Application has failed to initialize" error is related to missing imports from dlls; combined with the 0xC0000022 it may mean that a dll needed by your application cannot be loaded because of an access denied error (maybe the user hasn't got the rights to open/execute that file).
通常“应用程序初始化失败”错误与缺少 dll 导入有关;结合 0xC0000022 可能意味着由于访问被拒绝错误(可能用户没有打开/执行该文件的权限)而无法加载您的应用程序所需的 dll。
回答by Matteo Italia
Try running with the dependency walker. http://dependencywalker.com/
尝试使用依赖项walker 运行。http://dependencywalker.com/
It does static analysis of dependencies, and it can also trace through the startup of an application.
它对依赖进行静态分析,还可以跟踪应用程序的启动。
回答by Traveling Tech Guy
If I recall correctly, exception code c0000022 stands for Access Denied. Usually, it means Windows blocked access to a resource, like a domain controller or a driver.
如果我没记错的话,异常代码 c0000022 代表拒绝访问。通常,这意味着 Windows 阻止了对资源的访问,例如域控制器或驱动程序。
You haven't specified the nature of your application, but it is evident from the stack dump that it deals with 3D/OpenGL devices. Perhaps your issue lies with a misconfigured driver or library. I suggest testing on another machine and/or re-installing your drivers.
您尚未指定应用程序的性质,但从堆栈转储中可以明显看出它处理 3D/OpenGL 设备。也许您的问题在于配置错误的驱动程序或库。我建议在另一台机器上测试和/或重新安装您的驱动程序。