Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug exceptions in unknown code?

I have a program that uses external libraries. One of the libraries (responsible for a camera hardware) starts a thread and crashes unpredictably. Sometimes every 2 minutes, sometimes not for an hour. There's no obvious trigger. The exception is not caught be the thread, which leads to a termination of the application. :(

Luckily I can stop the application in the moment the exception is raised by the RaiseException() function from the kernel32.dll. There are no other functions on the call stack of which I know what they are for.

The debugger told me, that it's a std::bad_alloc exception. How does the debugger know that? Can I get more information about the exception somehow? If necessary, I would look into the Disassembly, but I don't know where to look to get the information.

I'm using Visual Studio C++ 2010, am well acquainted with assembler and have some understanding of the WINAPI. We want to release this software soon and this bug MUST dissappear.

like image 662
Ralph Tandetzky Avatar asked Oct 06 '22 21:10

Ralph Tandetzky


1 Answers

Use Windbg instead, that is a hard-core debugger that hides nothing and exposes things 'as they are'. Using sxe syntax enable the desired exception (Windgb will enable to break at any SEH type, not only C++). Windbg also has a clear distinction between first chance exception and second chance exception. You should figure out then whether this is a C++ exception being raise or a more fundamental SEH type like perhaps an AV.

like image 81
Remus Rusanu Avatar answered Oct 10 '22 02:10

Remus Rusanu