Re: CORRECTION Re: confused by exception handling in VC 2008
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:efgdk4do0kpp461nrdd4pfb5aijlt9bfei@4ax.com...
Note that the issue has nothing to do with the use of C++ exceptions, it
has to do with
the use of C++. An SEH is a stack-strip operation, and no destructors
will be called in
any pending context where local variables can be declared. Overall, you
can assume that
using SEH in a C++ program will introduce the possibility of memory leaks,
information
loss, compromised behavior, and in general cannot be depended upon to
result in a viable
program as a result. Only under some extremely limited scenarios will it
function at all.
You should try to avoid its use
*****
Actually, I'm not even convinced I need __try/__catch since I use a global
handler set by SetUnhandledExceptionFilter() to handle Win32 exceptions at
the moment.
****
Unless it does a throw(), it will cause serious malfunctions in C++ code
in general.
joe
Thanks Joe. My unhandled exception filter does not 'throw', it performs
critical operations and then calls ExitProcess() or restarts itself so the
user doesn't see the crash.
If I do need SEH in the future, I will take yours and Alan's advice about
using /EHa and _set_se_translator(). This seems to have some disadvantage
according to Doug Harrison: http://members.cox.net/doug_web/eh.htm, but I'm
not exactly sure how he proposes to use __try/__except, especially when we
also need to use try/catch for C++ exceptions in the same code. For now,
I'll avoid the issue by continuing to use SetUnhandledExceptionFilter() for
my limited needs.
-- David