System.ExecutionEngineException Failure

Alex picture Alex · Jun 8, 2009 · Viewed 47.7k times · Source

I've been trying to find out more about this problem and I'm not having much luck. I keep reading that applications should not have this error come up and although that's all fine and dandy, it doesn't tell me what can cause this error to show up.

I know this question is very broad as I'm sure there can be multiple causes for this error so I'll try to narrow it down a bit.

I'm working in VS2003 developing an application that uses C++.NET

The application uses mostly unmanaged code and little managed code (due to heavy interference by the garbage collector). So I'd rate it 95% unmanaged, 5% managed

I've read somewhere that unstable/buggy/incorrect unmanaged code can mess up parts of the CLR memory rendering it corrupt and throwing this error.

Since 95% of the application is unmanaged, I'm not sure where to start looking. Maybe the few classes that interact between managed and unmanaged? What about marshalling data from managed to unmanaged? Can a bad null pointer cause this failure? What other problems can cause this? Array Index out of bounds? What about a Null Object?

Any information/paper/article that can give a nice list of possible causes for the System.ExecutionEngine failure would be appreciated!


Based on answers this exception can be caused in multiple scenarios, mentioning htem in answer for better visibility.

List of possible causes/scenarios -

Possible workarounds/solutions -

Answer

Danië1 picture Danië1 · Apr 24, 2012

This should not be taken too seriously, but I managed to get this exception while having some fun with reflection:

typeof(IntPtr).GetField("Zero").SetValue(null, new IntPtr(666));