Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a program when it crashes w/out exception?

One of my programs crashes periodically, but I don't know why. I'm running it in debug mode, but nothing pops up. The program just suddenly exits. I've had other bugs that do throw an exception...but not this one. Is there a magical way of catching it or something?

like image 553
mpen Avatar asked Sep 25 '10 04:09

mpen


People also ask

How do you debug a crashed application?

You can use the stack trace available in the report details if you are using Play Console or the output of the logcat tool. If you don't have a stack trace available, you should locally reproduce the crash, either by manually testing the app or by reaching out to affected users, and reproduce it while using logcat.

How do I break an exception in Visual Studio?

Tell the debugger to break when an exception is thrownIn the Exception Settings window (Debug > Windows > Exception Settings), expand the node for a category of exceptions, such as Common Language Runtime Exceptions. Then select the check box for a specific exception within that category, such as System.

How do I stop Visual Studio from breaking on exception?

To turn off stop on exceptions press " Ctrl + Alt + E ". This will open the Exceptions window . Untick "Common Language Runtime Exceptions - Thrown". That would prevent it from pausing from within the delegate, but not when it's rethrown on Wait .


2 Answers

Presumably you're running it from within Visual Studio and for some reason it's not stopping in the debugger with an uncaught exception, in which case you could try catching the crash from outside of Visual Studio. See my answer at System.AccessViolationException from unmanaged code?, in particular how to capture a crash dump.

If it only crashes periodically, but within a reasonably short period of time, start with Sysinternals procdump. Start your executable from outside Visual Studio, then run:

procdump -e <YourExecutableNameOrPid>

and wait for it to harvest a crash dump - assuming it exits due to an unhandled exception - then load the crash dump into VS 2010 or WinDbg.

like image 105
Sean Fausett Avatar answered Sep 30 '22 09:09

Sean Fausett


The program just suddenly exits

definitely check that your code, or one of the libs you use, does not call exit() (yeah might sound too simple, but we once lost hours tracing random programs shutdowns back to exit() calls..). If so, put a breakpoint there or change to throw(), then run again. If not, Sean's answer seems legit.

like image 37
stijn Avatar answered Sep 30 '22 10:09

stijn