Uncategorized

Fatal Execution Engine Error on x64 Framework

I got two FEEE cases in a row last week, both of them for the same cause so I thought to blog about it hoping to save
some stress and headshakes to someone else.

The affected platform is 64 bit Framework (32 bit works fine), either Web or Windows application: randomly the
application crashes and if you check your event log you’ll find messages like the following:

Event Type:      Error
Event Source:   .NET Runtime
Date:                12-02-2009
10:58:36
User:                N/A
Computer:       <computername>
Description: .NET Runtime
version 2.0.50727.3082 – Fatal Execution Engine Error (000006427F8A5DC8) (80131506)

The stack of the faulting thread looks like this:

0:025> kpL1000
Child-SP          RetAddr           Call Site
00000000`0643e350 00000642`78acb013 mscorwks!COMCryptography::_DecryptData+0x329
00000000`0643e590 00000642`801f4b87 mscorlib_ni!System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(<HRESULT 0x80004001>)+0x123
00000000`0643e620 00000642`801f25c7 CryptoSample!MyCryptoClass.Decrypt(<HRESULT 0x80004001>)+0xf7
00000000`0643e960 00000642`bc8e449b System_Web_ni!System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute(<HRESULT 0x80004001>)+0x257
00000000`0643ea10 00000642`bc8f2215 System_Web_ni!System.Web.HttpApplication.ExecuteStep(<HRESULT 0x80004001>)+0xab
00000000`0643eab0 00000642`bc8e3553 System_Web_ni!System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(<HRESULT 0x80004001>)+0x1a5
00000000`0643eb60 00000642`bc8e7874 System_Web_ni!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(<HRESULT 0x80004001>)+0xd3
00000000`0643ebc0 00000642`bc8e745c System_Web_ni!System.Web.HttpRuntime.ProcessRequestInternal(<HRESULT 0x80004001>)+0x1c4
00000000`0643ec50 00000642`bc8e608c System_Web_ni!System.Web.HttpRuntime.ProcessRequestNoDemand(<HRESULT 0x80004001>)+0x7c
00000000`0643ec90 00000642`7f602322 System_Web_ni!System.Web.Hosting.ISAPIRuntime.ProcessRequest(<HRESULT 0x80004001>)+0x18c
00000000`0643edc0 00000642`7f503bb3 mscorwks!CallDescrWorker+0x82
00000000`0643ee20 00000642`7f5251f8 mscorwks!CallDescrWorkerWithHandler+0xd3
00000000`0643eec0 00000642`7f525563 mscorwks!ForwardCallToManagedMethod+0x160
00000000`0643ef60 00000642`7f544738 mscorwks!COMToCLRWorkerBody+0x35b
00000000`0643f1c0 00000642`7f50c8ae mscorwks!COMToCLRWorkerDebuggerWrapper+0x50
00000000`0643f230 00000642`7f60249e mscorwks!COMToCLRWorker+0x366
00000000`0643f520 00000642`fff58293 mscorwks!GenericComCallStub+0x5e
00000000`0643f5d0 00000642`fff58633 webengine!HttpCompletion::ProcessRequestInManagedCode+0x2a3
00000000`0643fa80 00000642`fff9abf4 webengine!HttpCompletion::ProcessCompletion+0x63
00000000`0643fac0 00000642`7f48dc77 webengine!CorThreadPoolWorkitemCallback+0x24
00000000`0643faf0 00000642`7f4a289a mscorwks!UnManagedPerAppDomainTPCount::DispatchWorkItem+0x157
00000000`0643fb90 00000642`7f41f0ac mscorwks!ThreadpoolMgr::WorkerThreadStart+0x1ba
00000000`0643fc30 00000000`77d6b6da mscorwks!Thread::intermediateThreadProc+0x78
00000000`0643ff80 00000000`00000000 kernel32!BaseThreadStart+0x3a

0:025> !clrstac
OS Thread Id: 0x1258 (25)
Child-SP RetAddr Call Site
000000000643e590 00000642801f4b87 System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[], Int32, Int32)
000000000643e620 00000642801f25c7 MyCryptoClass.Decrypt(System.String, System.String, Boolean)
000000000643e960 00000642bc8e449b System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
000000000643ea10 00000642bc8f2215 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)
000000000643eab0 00000642bc8e3553 System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(System.Exception)
000000000643eb60 00000642bc8e7874 System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object)
000000000643ebc0 00000642bc8e745c System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)
000000000643ec50 00000642bc8e608c System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest)
000000000643ec90 000006427f602322 System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)

If in your code you are calling Convert.FromBase64String (or CryptoAPITransform.TransformFinalBlock directly) assure you
are not passing an empty string as the value to convert, for example:

Public Function Decrypt(ByVal Source As String) As String

Dim byteArr As Byte() = System.Convert.FromBase64String(Source)

[…]

End Function

should instead look like this:

Public Function Decrypt(ByVal Source As String) As String
    'convert from Base64 to binary

If IsNullOrEmpty(Source) Then
Return String.Empty
End If

Dim byteArr As Byte() = System.Convert.FromBase64String(Source)

[…]

End Function

Carlo

Quote of the day:
The world is full of people whose notion of a satisfactory future is, in
fact, a return to the idealized past. – Robertson Davies

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.