Re: stack questions
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Mon, 23 Oct 2006 14:17:02 +0200
"DC" <***@***.com> wrote in message
news:e8Ym2Wc9GHA.4084@xxxxxxxxxxxxxxxxxxxxxxx
| Hi all,
|
| First of all, let me asure you you will not be doing my homework for me if
| you are good enough to reply - I have been a professional programmer for a
| couple of years now, I just never studied Computer Science so I like to
try
| and 'catch up' on stuff like this at the weekend.
|
| Having said that I have a couple of questions around the excution stack,
in
| particular 2 things are bothing me:
|
| 1. It is said that on encountering an exception, the execution engine
| "unwinds" the call stack looking for a suitable exception handler. In the
| example below can we assume that the address of the error handling code is
| pushed onto the stack as the return address before executing the try block
| and that, infact, the code within the try block is in itself executed as a
| function call within it's own stack frame? This can't be the answer though
| as the catch block only executes where the stack is unwinding 'in error'
not
| simply in unwinding during normal flow. So what is really going on??
|
| try
| {
| //some work
| }
| catch
| {
| //handling code
| }
|
A two phase exception handling model is employed by the CLR, and CLR
exceptions are implemented on top of the Windows SEH mechanism (as are the
C++ exceptions).
When an exception is thrown, the CLR initiates the first phase which consist
of a stack walk to search for an appropriate exception handler (the one
who's filter is able to deal with the exception!), in the second phase the
stack is unwound until the frame containing the handler is reached. Note
that unwinding the stack, causes the finally blocks on the unwounded frames
to be executed.
More gory detail, can be found here:
http://blogs.msdn.com/cbrumme/archive/2003/10/01/51524.aspx
Willy.
.
- References:
- stack questions
- From: DC
- stack questions
- Prev by Date: Re: generic class with numeric type?
- Next by Date: Re: How to open an URL
- Previous by thread: Re: stack questions
- Next by thread: Basic Newbie question
- Index(es):
Relevant Pages
|