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?
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 http://stackoverflow.com/questions/3652380/system-accessviolationexception-from-unmanaged-code/3655392#3655392, 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.
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.
You can find more suggestions at the following similar post: Third-party dll crashes program with no exception thrown.