Corrupted state exceptions (CSE) through AppDomain

For some source data, .NET 4.0 no longer catches CSE by default: http://msdn.microsoft.com/en-us/magazine/dd419661.aspx

I am working on an application that runs code in the new AppDomain. If this code throws a CSE, this exception bubbles up to the main code if it is not handled. My question is: can I safely assume that the CSE in the second AppDomain will not damage the state of the main AppDomain and thus exit the second AppDomain and continue working with the main AppDomain?

+4
source share
1 answer

In the context of a distorted state exception, in general, you can no longer consider anything true. The essence of these exceptions is that something happened, usually due to unmanaged unmanaged code, which violated some basic assumptions about what the Windows or CLR does about the memory structure. This means that, theoretically, the very structures that the CLR uses to track application domains in memory can be damaged. The kinds of things that cause CSE generally indicate that the situation is catastrophically wrong.

Having said all this, regardless of the fact, in some cases, you can make a determination that it is safe to continue with a certain exception. For example, EXCEPTION_STACK_OVERFLOW can probably be restored, and EXCEPTION_ACCESS_VIOLATION usually indicates that Windows caught a potential error before it could screw something up. It is up to you if you are willing to take risks, depending on how much you know the code that throws the CSE in the first place.

+1
source

Source: https://habr.com/ru/post/1414466/


All Articles