Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:52:24+00:00 2026-05-27T16:52:24+00:00

At least according to a description of Mono’s exception handling implementation , all the

  • 0

At least according to a description of Mono’s exception handling implementation, all the x86 registers are saved when an exception is thrown. Besides the stack pointer (ESP), frame pointers (EBP), instruction pointers (EIP), and the register that holds the exception object, why are the other registers saved as well? Why save that the entire context when in .NET is there is no mechanism to continuing executing at the point immediately after a throw?

UPDATE:

EMCA states the following in section 12.3.2.4 Overview of exception handling:

  • An exception object describing the exception is automatically created by the CLI and pushed onto
    the evaluation stack as the first item upon entry of a filter or catch clause.

  • Execution cannot be resumed at the location of the exception, except with a filter handler.

I don’t know how the “except with a filter handler” can be accomplished in light of the previous statement. Also the description of the endfilter opcode only has two outcomes: “continue searching for another exception handler” or to execute the handler (which would execute another block of CIL opcodes.) It’s missing a “resume” option. Therefore, I interpret this discrepancy in the specification to basically mean .NET does not support continuing executing at the point immediately after a throw. Maybe it was considered at some point but never fully realized and implemented.

UPDATE 2:

Someone pointed out that “resume” could simply happen if no filter handler opts to catch the exception. However, the specification for throw states: “the throw instruction throws the exception object on the stack and empties the stack.” The emptying of the stack would make it impossible to execute the code immediately after the throw statement, as that code might require something on the stack.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:52:25+00:00Added an answer on May 27, 2026 at 4:52 pm

    You’re looking at implementation details: they usually aren’t a one to one match to the ECMA spec for many possible reasons (like ease of implementation, code sharing, providing additional semantics, future-proofing, optimizations etc).

    In this particular case there are several considerations.

    Mono performs exception handling based on a view of the processor state called MonoContext: as this structure is used also in other places, it contains all the relevant registers even if some may not be needed in some particular cases. In particular, exception handling can be initiated also from a cpu exception where all the registers need to be restored, so all of them are collected.

    Someone already observed that the context is used also for the debugger.

    Consider also the case of a method with a try/catch with the catch being a simple local var setting. Now, an advanced register allocator might put a local var that is used both before the throw (note the throw may be implicit, like a null reference, so handled by the cpu exception path) and after the catch in a register like edx. If you don’t save all the registers at the throw/exception point you corrupted the program state as edx would get overwritten during exception handling.

    As a last comment: are you worried that saving the few extra registers is wasting cpu cycles? If you actually count the cycles spent, they are completely in the noise wrt all the stuff that needs to happen during exception handling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apparently (at least according to gcc -std=c99 ) C99 doesn't support function overloading. The
Shouldn't the compiler automatically cast to a double in the following? At least according
At least on my local instance, when I create tables, they are all prefixed
I recently ran into an issue at work in which, at least according to
On 64-bit architectures, long int , according to gcc is at least an int64_t
GPGPU as a lot of potentiality on many tasks (not all), especially handling matrices
I believe I have the syntax correct, at least according to my textbook. This
I am using the Maven-Shade-Plugin to create a runnable Uber-jar. According to the last
Least Recently Used (LRU) Cache is to discard the least recently used items first
At least two brilliant programmers, Linus Torvalds and Guido von Rossum, disparage the practice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.