Re: Try Finally...

From: Martin Harvey (Demon account) (martin_at_nospam_pergolesi.demon.co.uk)
Date: 10/25/04


Date: Mon, 25 Oct 2004 18:14:58 GMT

On Mon, 25 Oct 2004 14:45:10 +0100, Duncan McNiven
<duncan@mcniven.net> wrote:

>No it won't. It will continue at the next outer try .. finally or try
>... except construct. Since you haven't provided one, execution goes to
>the application's default exception handler, and terminates there.

I'm amazed you folks are even having this argument. It's real simple.
The only real difficuly that is going on is understanding the
different viewpoint between language constructs and S.E.H. constructs.

try ... except and try...finally are both the same thing in S.E.H.
terms:

They both create and register an exception handling "callback
function" which is the body of the "finally" or "except" block. These
blocks are chained together in effectively the same order as the
stack.

when an exception is raised, the records are traversed and the stack
is unwound. Now, I'm going to skip the details of the fact that the
entire chain is traversed twice, and will simply say that the
difference is that with a "finally" block, the default behaviour is to
continue the unwind process (resulting in possible termination of the
program, and with an "except" block, the default behaviour is to
indicate that the exception has been handled, and it is possible to
continue.

Now ... as concerns continuing versus not continuing.... there are
several points where confusion may be present, and I'll attempt to
clear this up.

- Skipping the subtleties, if I remember rightly, there are basically
three things that an S.E.H registered handler can do

- continuing the program because the exception has been handled.
- continuing the search for an appropriate handler.
- stopping the whole shebang at that point, and terminating the app.

If LDB wants to implement a custom mechanism, the thing one should be
doing with finally blocks is NOT terminating the program, but
continuing the search. HOWEVER, this may well require some custom code
to unwind the stack.

Oh, and BTW, I'd recommend people who don't know how S.E.H works
internally at least do a google search and a bit of reading - it's
quite interesting.

MH.



Relevant Pages

  • Re: Exception Handling...
    ... >>The try key word results in the current stack frame base, ... > private data on top of the Exception Registration... ... is the address of the exception handler. ... >>Immediately following this jump, there is inserted a jump to ...
    (comp.lang.pascal.delphi.misc)
  • Re: Thread Abort and Unhandled Exception Event
    ... event, not an exception handler. ... I might have called that a handler, ... that once the application is terminating, ... handler in the thread itself (that is, try/catch at the top of the thread ...
    (microsoft.public.dotnet.framework)
  • Re: ada compiler?
    ... high that the exception handler itself will overflow the stack (e.g. ... Storage_Error (without any further operations in the handler) would fail the ...
    (comp.lang.ada)
  • Re: VB6 How to find calling routine
    ... it means once a handler has captured ... an exception, most of the original stack context has gone because the stack ... to track all the calling routines is just too much work for too little ...
    (comp.lang.basic.visual.misc)
  • Re: crash in release build
    ... If you don't have any idea where it's crashing (like the call stack), ... // Add the event handler for handling UI thread exceptions to the ... // Set the unhandled exception mode to force all Windows Forms errors ... // Add the event handler for handling non-UI thread exceptions to the ...
    (microsoft.public.dotnet.languages.csharp)