Enable C++ Exceptions: Yes With SEH Exceptions (/EHa)
"._set_se_translator()
with it.set_terminate()
and set_unexpected()
.EXCEPTION_STACK_OVERFLOW
exception.None of the things I've tried has resulted in picking up the EXCEPTION_STACK_OVERFLOW
exception.
Does anyone know how to guarantee getting a a chance at this exception during runtime in release mode?
(Considering the name of this site, I'm kind of surprised this question isn't on here already!)
With a solution open in Visual Studio, use Debug > Windows > Exception Settings to open the Exception Settings window. Provide handlers that respond to the most important exceptions. If you need to know how to add handlers for exceptions, see Fix bugs by writing better C# code.
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 .
For details, see How to: Open Project Property Pages. Click the C/C++ folder. Click the Code Generation property page. Set Enable C++ Exceptions to Yes (/EHsc).
In visual studio, the Debug menu -> Exceptions. You can check and uncheck exceptions. You can have it break on handled thrown ones, or unhandled ones.
Everything prior to windows xp would not (or would be harder) generally be able to trap stack overflows. With the advent of xp, you can set vectored exception handler that gets a chance at stack overflow prior to any stack-based (structured exception) handlers (this is being the very reason - structured exception handlers are stack-based).
But there's really not much you can do even if you're able to trap such an exception.
In his blog, cbrumme (sorry, do not have his/her real name) discusses a stack page neighboring the guard page (the one, that generates the stack overflow) that can potentially be used for backout. If you can squeeze your backout code to use just one stack page - you can free as much as your logic allows. Otherwise, the application is pretty much dead upon encountering stack overflow. The only other reasonable thing to do, having trapped it, is to write a dump file for later debugging.
Hope, it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With