Program error with 0xC000000D and no exceptions - how to debug it?

I have a Visual C ++ 9 Win32 application that uses a third-party library. When a function from this library is called with a specific set of parameters, the program crashes with "exception code 0xC000000D".

I tried to connect the Visual Studio debugger - no exceptions are thrown (neither C ++ nor structured as access violations) and terminate() also not called. However, the program simply ends silently.

How does it happen that a program simply terminates abnormally but does not stop in the debugger? How can I localize the problem?

+5
source share
3 answers

What STATUS_INVALID_PARAMETER, use WinDbg to track who dumped it (i.e. attach WinDbg, sxe eh , then g .

+5
source

Other answers and comments on this question helped a lot. Here is what I did.

I notice that if I run the program in the Visual Studio debugger, it just ends silently, but if I run it without a debugger, it will work with the message field (a regular Windows message box that says that I lost my unsaved data, and everything is so sorry).

So, I launched the debug wihtout program, resolved it to crash, and then - while the message box was still there - connected the debugger and clicked "Break". Here's the call stack:

 ntdll.dll!_KiFastSystemCallRet@0 () ntdll.dll!_ZwWaitForMultipleObjects@20 () + 0xc bytes kernel32.dll!_WaitForMultipleObjectsEx@20 () - 0x48 bytes kernel32.dll!_WaitForMultipleObjects@16 () + 0x18 bytes faultrep.dll!StartDWException() + 0x5df bytes faultrep.dll!ReportFault() + 0x533 bytes kernel32.dll!_UnhandledExceptionFilter@4 () + 0x55c bytes //SomeThirdPartyLibraryFunctionAddress //SomeThirdPartyLibraryFunctionAddress //SomeThirdPartyLibraryFunctionAddress //SomeThirdPartyLibraryFunctionAddress //OurCodeInvokingThirdPartyLibraryCode 

so it’s obvious that there is some problem inside the trird-party library. According to MSDN, UnhandledExceptionFilter() is called in fatal situations, and obviously the call is being executed due to some problem in the library code. Therefore, we first try to solve the problem with the library provider.

+2
source

If you do not have the source and debugging information for your third-party library, you will not be able to enter it using the debugger. As I see your options:

  • Combine a simple test case illustrating failures and send it to the library developer
  • Wrap this library function in your own code that checks illegal parameters and throws an exception / returns an error code when they are passed by your own application
  • Rewrite parts of the library that do not work or use an alternative

It is very difficult to fix code that is provided only as an object

Change You can also exit gracefully using __try __finally around your main message loop, something like

 int CMyApp::Run() { __try { int i = CWinApp::Run(); m_Exitok = MAGIC_EXIT_NO; return i; } __finally { if (m_Exitok != MAGIC_EXIT_NO) FaultHandler(); } } 
+1
source

Source: https://habr.com/ru/post/885812/


All Articles