3

I want to understand when EXCEPTION_REGISTRATION_RECORDs get created on the stack.

  • Are they created when the program starts?
  • Are they created when we enter the function?
  • Or are they created only when the exception occurs?

Is it true that there is one EXCEPTION_REGISTRATION_RECORD per try/catch?

3
  • Could you please clarify one thing. You tagged it as seh, but you mention try/catch. Now in MSVC C++ exceptions are implemented in terms of SEH, but are you solely interested in the C++ side of things or in general?
    – 0xC0000022L
    Commented Feb 17, 2023 at 9:41
  • I mean a MSVC C++ try/catch. I am interested in the wide general thing
    – Bob5421
    Commented Feb 17, 2023 at 10:39
  • I replaced my original answer because I was somehow describing the exception_record rather than the exception_registration_record. Commented Feb 25, 2023 at 23:33

1 Answer 1

4

EXCEPTION_REGISTRATION_RECORD is placed on the stack in anticipation of an exception occurring. The "try" will put one there. The record is part of a chain, for as many nested "try" statements as exist. The nesting includes one function calling another function from within a try block. Windows will also put a top-most handler there before the program starts, so there is always one on program start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.