Having any intermittent crashes with .Net 4.0 running in x64?


Came across this recently: “ExecutionEngineException occurs during Garbage Collection“ and the subsequent KB article on support.microsoft.com.  Last year I was finding some random crashes in a couple of .Net 4.0 Windows Service Applications, and this might have been part of the problem.

Right, so what does this mean?  Basically there’s some heap corruption occurring when the .Net 4.0’s runtime attempts to perform garbage collection.  It (to me) looks like a bit of a race condition between foreground and background concurrent GC actions.

From the KB article:

This bug can be encountered when the Garbage Collector is freeing and compacting memory. The error can happen when the Concurrent Garbage Collection is enabled and a certain combination of foreground Garbage Collection and background Garbage Collection occurs. When this situation happens you will see the same call stack over and over. On the heap you will see one free object and before it ends you will see another free object corrupting the heap.

..and the (current) resolution is to disable concurrent garbage collection.  To do so there’s a configuration you can set which is described here.

Want to know the real kick in the pants? 

By default, the runtime runs garbage collection concurrently

Let’s just hope there’s a hotfix for this one soon..

References:

http://support.microsoft.com/kb/2679415
http://msdn.microsoft.com/en-us/library/at1stbec.aspx


About Rob Sanders

IT Professional and TOGAF 9 certified architect with nearly two decades of industry experience, 18 years in commercial software development and 11 years in IT consulting. Check out the "About Rob" page for more information.

Leave a comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>