We've encountered an access violation on our test machine, in Entity Framework code. I'm wondering if this could potentially be due to a threading bug, or if it's more likely due to hardware issues.
Here is a partial call stack:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Data.Common.Internal.Materialization.CoordinatorFactory`1..ctor(Int32 depth, Int32 stateSlot, Expression hasData, Expression setKeys, Expression checkKeys, CoordinatorFactory[] nestedCoordinators, Expression element, Expression elementWithErrorHandling, Expression initializeCollection, RecordStateFactory[] recordStateFactories)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at System.Data.Common.Internal.Materialization.CoordinatorScratchpad.Compile()
This happened in our ASP.NET app on IIS 7 (Server 2008 R2 SP1), using Entity Framework 4 to access SQL Server 2008 R2. I've read about access violations with EF and SQL Server CE, but we are using the full SQL Server. We aren't directly interacting with any native code from our app - no P/Invoke or COM interop.
This has only happened once. Personally I think it's a problem with the machine, not the application... the machine has BSOD'd a couple times before. But I was asked to look into it as a possible bug.
I'll look into setting up DebugDiag to catch this if it happens again. Does anyone have any other suggestions?
Thanks,
Richard