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!)
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.