what is stack unwinding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dami
    New Member
    • Mar 2007
    • 4

    what is stack unwinding

    what is use of stack in exception handling.. and what is stack unwinding
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by dami
    what is use of stack in exception handling.. and what is stack unwinding
    Which language? Java, .NET?

    Comment

    • MMcCarthy
      Recognized Expert MVP
      • Aug 2006
      • 14387

      #3
      As there has been no reply regarding language this question is being moved to the Miscellaneous Discussions forum.

      ADMIN

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Stack unwinding is the name given to the process of undoing all of the processing in a series of nested calls.

        That is:

        Funcation A calls Function B calls Function C.

        In function C there are 3 stack frames. Should FunctionC throw an exception, the program will go directly to the nearest catch block. That is, FunctionC will not return. Hence, FunctionB will not return andhence FunctionA will not return. That means the stack frame for FunctionC cannot be cleaned up, nor the stack frame for FuncitonB and the stack frame for FunctionC.

        Stack unwinding applies to the cleaning up of FunctionB and FunctionA stack frames so that the program is in the state that FunctionA was never called in the first place. FunctionC must clean itself up before exiting top the catch block.

        This applies to C++, Java and C#.

        Comment

        Working...