views:

434

answers:

5

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.

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?

A: 

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.

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.

Traveling Tech Guy
A: 

Most likely you (or glut32.dll) are dependent on a DLL and you either don't have access to it (c0000022 is Access Denied) or some other process has it open for exclusive access. Did you check the event log?

You can also use Dependency Walker to figure out the DLL dependencies and find out which dll is the issue. You could also set a break point at LoadLibrary and see which one fails.

I would also recommend using SysInternals tools to help figure out which process might be holding onto the dll you require. (Sorry, I don't remember exactly which one. Perhaps process explorer).

Hope that helps.

Moron
There do not appear to be any events in the event log related to this. Dependency walker shows all the DLLs but fails to see any problems. Putting a breakpoint in LoadLibray never seems to get hit, though from the debugger spew, it looks like it never even tries to put in the breakpoint until AFTER the exception stuff that is causing the problem.
Chris Dodd
You should be able to start the exe in the debugger so that it breaks immediately (look for command line options of debugger). Once it is broken, you can set the LoabLibrary break point and let the exe run and the loading continue.
Moron
A: 

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).

Matteo Italia
I saw now the resolution... wow, my psychic debugging powers were right!
Matteo Italia
+1  A: 

Try running with the dependency walker. http://dependencywalker.com/

It does static analysis of dependencies, and it can also trace through the startup of an application.

jdv
+4  A: 

Following up on Moron's answer, You should run 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 any process troubleshooting, it's an amazing time-saver.

Bahbar
This tool was finally able to identify where the problem was -- missing execute permissions on glew32.dll
Chris Dodd