Re: Exception Handling - help!

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: David Levine (noSpamdlevineNNTP2_at_wi.rr.com)
Date: 11/03/04


Date: Tue, 2 Nov 2004 18:34:45 -0600

Something to keep in mind is that my current knowledge is that the only
language that supports user filters is VB, and it does not support calling
methods, only evaluating simple expressions. To call a user-filter you would
have to write the code directly in IL.

That being said, my understanding of the sequence is much as you have
described it...the first pass searches for a handler, executing user filters
as it goes. Since the stack has not yet been unwound then any methods
invoked during the user filter would have to be on top of the stack, which
implies that those routines also have access to the stack frame in which the
original exception occurred (this could be of use to a clever tool
developer). Basically, the stack frames for the user filters are on top of
the faulted stack, just as you described it.

If another exception occurs within a user filter then the runtime would have
to treat this as a nested exception. I don't remember how the runtime treats
this - I think this wipes out the original exception and this triggers a
whole new round of stack walking searching for a handler, but it could also
treat this as a fatal error and terminate the app. This isn't well
documented.

After the user filter executes, if it returns a value that tells the runtime
to execute the handler the runtime then remembers the catch block that will
handle the original exception, executes the 2nd pass, which executes finally
blocks, and this continues until the stack is unwound and control resumes
within the catch handler.

"George" <George@discussions.microsoft.com> wrote in message
news:DBE66BDF-B746-4077-89EE-8996635E8B78@microsoft.com...
> My problem is related to the user-filters used in CLR. They are executed
> in
> the 1st pass of the exception handling mechanism (it is a 2-pass
> mechanism!).
> But their execution can involve calling other methods, right? How would
> then
> look the CPU stack of call frames?
>
> More concrete, suppose the following example:
>
> The stack of call frames looks as follows:
>
> m2
> m1
> Main
>
> In m2 (topmost frame), we get an exception. We start looking for an
> suitable
> handler. In m2, we find none. In m1, we find a user-filter that might
> handle
> our exception. We have to execute the user-filter, right? Suppose this
> implies calling the method f1 which in turn, calls the method f2. We are
> still in 1st pass of the stack-walk!
>
> How does it look now the stack of call frames? I don't think it looks as
> follows:
>
> f2
> f1
> m2
> m1
> Main
>
> When are popped of the stack f2 and f1?
>
> Any ideas would be very helpful to me!
> Thank you very much in advance!
> George



Relevant Pages

  • Re: Scheme Virtual Machine
    ... Minimal c/c++ made core for the executable file everything else in the ... I had a similar idea in mind when writing my Implementation of scheme ... The VM uses a stack to pass arguments. ... executes an if operation with a 'then' and an 'else' branch. ...
    (comp.lang.scheme)
  • Re: DEFCON 16 and Hacking OpenVMS
    ... the overflow that executes the code in the logical. ... that these exploits work by finding some OS-managed storage which is ... stack based buffer overflow scribbling over a return address. ... associated RTL routines are a NICE idea, one day maybe Billco and UNIX ...
    (comp.os.vms)
  • Re: Price of Creating Local Objects
    ... executes, then measurements will be more helpful. ... mentioning to a "stack" are referring to a possibly common implementation. ... problem for applications that use highly recursive algorithms. ...
    (comp.lang.cpp)
  • Re: Exlusive: Microsoft discovers "VirtualProtect" API call
    ... Gone are buffer overruns and stack overflow attacks ... > in Delphi compliant with that? ... God, you got me scared for a second... ... executes some machine code at run time. ...
    (borland.public.delphi.non-technical)