linq2sql Access violation on SingleOrDefault

1

I have .net 4.0 service that crashes from time to time, the code that is responsible for crash runs every few minutes on its own task with its own database context. After analyzing crash dump I get this managed call stack:

(TransitionMU)
0DBFE30C 72720900 mscorlib_ni!System.DefaultBinder.SelectMethod(System.Reflection.BindingFlags, System.Reflection.MethodBase[], System.Type[], System.Reflection.ParameterModifier[])+0x84
0DBFE34C 7271CE3E mscorlib_ni!System.RuntimeType.GetMethodImpl(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Reflection.CallingConventions, System.Type[], System.Reflection.ParameterModifier[])+0x9e
0DBFE380 72733261 mscorlib_ni!System.Type.GetMethod(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Type[], System.Reflection.ParameterModifier[])+0x41
0DBFE3A8 6A0168A5 System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler+Generator.GetReaderMethod(System.Type, System.Type)+0x81
0DBFE3C0 6A0154CA System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler+Generator.GenerateColumnAccess(System.Type, System.Data.Linq.SqlClient.ProviderType, Int32, System.Reflection.Emit.LocalBuilder)+0x4e
0DBFE49C 6A015217 System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler+Generator.GenerateColumnReference(System.Data.Linq.SqlClient.SqlColumnRef)+0x2b
0DBFE4B0 6A017D21 System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler+Generator.Generate(System.Data.Linq.SqlClient.SqlNode, System.Reflection.Emit.LocalBuilder)+0x121
0DBFE4C4 6A01190A System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler+Generator.GenerateAssignValue(System.Data.Linq.Mapping.MetaDataMember, System.Reflection.Emit.LocalBuilder, System.Data.Linq.SqlClient.SqlExpression, System.Reflection.Emit.LocalBuilder)+0x16e
0DBFE4FC 6A011788 System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler+Generator.GenerateMemberAssignment(System.Data.Linq.Mapping.MetaDataMember, System.Reflection.Emit.LocalBuilder, System.Data.Linq.SqlClient.SqlExpression, System.Reflection.Emit.LocalBuilder)+0x2d0
0DBFE560 6A011164 System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler+Generator.GenerateNew(System.Data.Linq.SqlClient.SqlNew)+0xaa8
0DBFE6D8 6A017CFF System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler+Generator.Generate(System.Data.Linq.SqlClient.SqlNode, System.Reflection.Emit.LocalBuilder)+0xff
0DBFE6EC 6A0130BA System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler+Generator.GenerateBody(System.Reflection.Emit.ILGenerator, System.Data.Linq.SqlClient.SqlExpression)+0x13a
0DBFE708 6A00E10D System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler.CompileDynamicMethod(Generator, System.Data.Linq.SqlClient.SqlExpression, System.Type)+0xbd
0DBFE730 6A00E29F System_Data_Linq_ni!System.Data.Linq.SqlClient.ObjectReaderCompiler.Compile(System.Data.Linq.SqlClient.SqlExpression, System.Type)+0x17b
0DBFE7BC 6A02199F System_Data_Linq_ni!System.Data.Linq.SqlClient.SqlProvider.GetReaderFactory(System.Data.Linq.SqlClient.SqlNode, System.Type)+0x5f
0DBFE7D4 6A01DE20 System_Data_Linq_ni!System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(System.Linq.Expressions.Expression)+0xfc
0DBFE7FC 69FDB28F System_Data_Linq_ni!System.Data.Linq.Table`1[[System.__Canon, mscorlib]].System.Linq.IQueryProvider.Execute[[System.__Canon, mscorlib]](System.Linq.Expressions.Expression)+0x3b
0DBFE814 70E265A0 System_Core_ni!System.Linq.Queryable.SingleOrDefault[[System.__Canon, mscorlib]](System.Linq.IQueryable`1<System.__Canon>, System.Linq.Expressions.Expression`1<System.Func`2<System.__Canon,Boolean>>)+0x120
0DBFE840 747F2376 Controller_ni!Service.ControllerBase.ControllerOperationManager.DoCheckState(CNTDB)+0x146
0DBFE96C 726D120D mscorlib_ni!System.Threading.Tasks.Task.InnerInvoke()+0x49
0DBFE978 726D16D6 mscorlib_ni!System.Threading.Tasks.Task.Execute()+0x2e
0DBFE99C 726D1949 mscorlib_ni!System.Threading.Tasks.Task.ExecutionContextCallback(System.Object)+0x15
0DBFE9A0 72724157 mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+0xa7
0DBFEA0C 72724096 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+0x16
0DBFEA20 726D17FB mscorlib_ni!System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)+0xcb
0DBFEA84 726D11B3 mscorlib_ni!System.Threading.Tasks.Task.ExecuteEntry(Boolean)+0xb3
0DBFEA94 72E1F147 mscorlib_ni!System.Threading.Tasks.ThreadPoolTaskScheduler.LongRunningThreadWork(System.Object)+0x17
0DBFEA98 72746ED4 mscorlib_ni!System.Threading.ThreadHelper.ThreadStart_Context(System.Object)+0x9c
0DBFEAA4 72724157 mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+0xa7
0DBFEB10 72724096 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+0x16
0DBFEB24 72724051 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x41
0DBFEB3C 72691CD2 mscorlib_ni!System.Threading.ThreadHelper.ThreadStart(System.Object)+0x4e
(TransitionUM)

FAULTING_IP: 
clr!WKS::gc_heap::find_first_object+c9
73581849 f70000000080    test    dword ptr [eax],80000000h

EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 73581849 (clr!WKS::gc_heap::find_first_object+0x000000c9)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000001
NumberParameters: 2
   Parameter[0]: 00000000
   Parameter[1]: 00000000
Attempt to read from address 00000000

CONTEXT:  00000000 -- (.cxr 0x0;r)
eax=00000000 ebx=0001ca2c ecx=0e516800 edx=00000000 esi=0e5164f0 edi=0e5164f0
eip=73581849 esp=0dbfd598 ebp=0dbfd5b8 iopl=0         nv up ei pl zr na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010246
clr!WKS::gc_heap::find_first_object+0xc9:
73581849 f70000000080    test    dword ptr [eax],80000000h ds:002b:00000000=????????

Any ideas what can cause such crash in managed code?

EDIT: SingleOrDefault queries for a database table for row by unique ID and the data it is requesting is pretty static (the requested data it present at the call time)

c#
linq-to-sql
task
native
access-violation
asked on Stack Overflow Oct 13, 2014 by Justinas Kanguras • edited Oct 14, 2014 by Justinas Kanguras

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0