Re: Combined usage of exception handling
- From: Severian <severian@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 31 Mar 2005 18:20:49 GMT
On Thu, 31 Mar 2005 02:48:46 -0800, "Eugene Gershnik"
<gershnik@xxxxxxxxxxx> wrote:
>Severian wrote:
>> int LogExcept(ULONG ecode, BOOL fatal, VOID **exp, LPCTSTR fmt, ...)
>> {
>> static volatile _declspec(thread) BOOL in_exception;
>
>
>First problem: How do you know that in_exception is not corrupted? It is
>just a location in memory after all
Of course I don't know that. but if either is corrupted, the exception
handler will let the exception go to the defaul SEH, and a "normal"
crash will occur.
>>
>> if (in_exception || fastcrash) /* Oops, things are really bad */
>
>
>Same thing about fastcrash
>
>> return EXCEPTION_CONTINUE_SEARCH;
>> in_exception = TRUE;
>> ...
>
>And here is the biggest problem. How do you know that whatever is behind
>"..." can actually run? Your stack, heap and static variables are all just
>locations in memory that can contain garbage at this point. This isn't
>theoretical. I have atually seen system fail horribly (no log, no debugger,
>nothing) on a customer site because somebody thought it was a good idea to
>do something like the code above.
>
>The *only* way to do post-mortem examination is from the safety of another
>process like Dr. Watson or a custom substitute that knows more about your
>app.
For the crashes we see in the real world (after alpha and beta
testing), with hundreds of thousands of users, 99% or more of them
produce valid, usable logs with stack traces (the most important
part). We also provide a command-line option to create a log while
running, which usually is able to pinpoint the other <1% of problems
(hangs, silent crashes).
In my main product, most crashes are read access violations in ODBC or
JET, due to misconfiguration on the client machine. The problems are
sometimes in TWAIN data sources and other things beyond our control,
such as missing or invalid DLLs, viruses, injected code from
poorly-written system utilities, or global hooks. Others are of course
due to our own bugs, and the exception logs are invaluable for all of
these.
Aside from producing a useful log, we present a more useful (and
truthful) error message:
A fatal exception error (%08x at %04x:%08x) has occurred in
<Program> or a Windows system component. Details have been
written to the log file:
%s.
(Since so many crashes are caused by ODCB/JET misconfiguration due to
terrible design by Microsoft, we like to share the blame!)
As for causing the system to fail, a real operating system has
separate processes that run in protected memory and a process failure
does not cause a system failure. System failures are generally caused
by operating system and driver bugs themselves. (Yes, it's possible to
crash or make the system unusable from user mode, but it's not likely
in an application that sticks to itself and leaves the system and
other processes alone.)
A Windows 9x/ME user, running in a half-protected environment, is
surely used to system crashes anyway!
Even Dr. Watson has to run code in the context of the failing process;
it is by no means failsafe.
>Having said that __try/__except/__finally has its uses usually around some
>low level "testing" code or to filter very specific, "safe" things like
>division by zero.
Yes, we use it for such very specific cases also; both directly and
indirectly for parameter validation in debug mode (IsBadReadPtr,
etc.).
--
Sev
.
- Follow-Ups:
- Re: Combined usage of exception handling
- From: Eugene Gershnik
- Re: Combined usage of exception handling
- References:
- Re: Combined usage of exception handling
- From: William DePalo [MVP VC++]
- Re: Combined usage of exception handling
- From: Severian
- Re: Combined usage of exception handling
- From: William DePalo [MVP VC++]
- Re: Combined usage of exception handling
- From: Severian
- Re: Combined usage of exception handling
- From: Eugene Gershnik
- Re: Combined usage of exception handling
- Prev by Date: Re: Algorithm question - binary matrix
- Next by Date: Re: Combined usage of exception handling
- Previous by thread: Re: Combined usage of exception handling
- Next by thread: Re: Combined usage of exception handling
- Index(es):
Relevant Pages
|