我们在带有 WPF 前端的 IIS 中托管了许多 WCF 服务。有时 IIS 会崩溃,看起来像是一个序列化错误,但不确定在哪里或什么对象失败了。我们怀疑它是实体框架对象集合的序列化(带有导航属性等),但是在内部测试时,有问题的对象可以很好地序列化。IIS 可能每天在现场崩溃一次/两次。有问题的对象被最终用户大量使用,这让我相信如果这是一个真正的序列化错误,那么我们每次都会看到 WCF 上的序列化失败?它可能仅在某些情况下失败,还是其他原因导致 IIS 像这样崩溃?我们发现这很难追踪。
事件日志中有一个来自源“WAS”的条目
为应用程序池“xxx”提供服务的进程与 Windows 进程激活服务发生了致命的通信错误。进程 ID 为“1016”。数据字段包含错误号。
这是使用 DebugDiag 工具捕获的内存转储/堆栈跟踪。
w3wp__appPoolName__PID__2932__Date__09_29_2016__Time_01_00_26PM__964__Ntdll!ZwTerminateProcess.dmp 中的以下线程正在调用 TerminateProcess 函数来杀死进程
( 39 )
2,13% 的线程被阻塞(1 个线程)
请查看线程的调用堆栈,看看它在做什么,最终调用 TerminateProcess 函数
线程 39 - 系统 ID 4564
入口点 clr!GetPrivateContextsPerfCounters+16f00 创建时间
29.09.2016 12:59:25 在用户模式下花费的时间 0 天 00:00:08.125 在内核模式下花费的时间 0 天 00:00:00.000该线程正在调用 TerminateProcess 函数来终止进程
该线程在堆栈上有 .net 异常的证据。查看以前的 .NET 异常报告(所有 .NET 线程堆栈中的异常)以查看相关异常的更多详细信息
.NET 调用堆栈
[[FaultingExceptionFrame]] System_Runtime_Serialization_ni!System.Xml.XmlBaseWriter.WriteStartElement(System.String, System.Xml.XmlDictionaryString, System.Xml.XmlDictionaryString)+3b System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlWriterDelegator.WriteStartElement(System.String, System .Xml.XmlDictionaryString, System.Xml.XmlDictionaryString)+23 动态类。将实体名称写入XML(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.XmlObjectSerializerWriteContext, System.Runtime.Serialization.ClassDataContract)+14b9 System_Runtime_Serialization_ni!System.Runtime.Serialization.ClassDataContract.WriteXmlValue(System.Runtime.Serialization.XmlWriterDelegator , System.Object, System.Runtime.Serialization.XmlObjectSerializerWriteContext)+31 System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(System.Runtime.Serialization.DataContract, System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, System .RuntimeTypeHandle, System.Type)+eb System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.RuntimeTypeHandle, System.Type, Int32, System.RuntimeTypeHandle, System.Type)+309 System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System.RuntimeTypeHandle)+247897 System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System.RuntimeTypeHandle)+6f DynamicClass。 WriteObjectListToXml(System.Runtime.Serialization.XmlWriterDelegator,System.Object,System.Runtime.Serialization.XmlObjectSerializerWriteContext,System.Runtime.Serialization。CollectionDataContract)+1aa System_Runtime_Serialization_ni!System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.XmlObjectSerializerWriteContext)+41 System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlObjectSerialize(SerializerWriteContext.InternalSerialize) System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System.RuntimeTypeHandle)+6f System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System.RuntimeTypeHandle)+6f DynamicClass.WriteKeyValueOfstringObjectListtGI2ndrTToXml(System.Runtime.Serialization.XmlWriterDelegator, System.对象, System.Runtime.Serialization.XmlObjectSerializerWriteContext, System.Runtime.Serialization.ClassDataContract)+176 System_Runtime_Serialization_ni!System.Runtime.Serialization.ClassDataContract.WriteXmlValue(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization。 XmlObjectSerializerWriteContext)+31 DynamicClass.WriteObjectsRemovedFromCollectionPropertiesToXml(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.XmlObjectSerializerWriteContext, System.Runtime.Serialization.CollectionDataContract)+1a1 System_Runtime_Serialization_ni!System.Runtime.Serialization.CollectionDataContract. System.Runtime.Serialization.XmlWriterDelegator、System.Object、System.Runtime.Serialization。XmlObjectSerializerWriteContext)+41 System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System.RuntimeTypeHandle)+6f System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlObjectSer。 InternalSerializeReference(System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System.RuntimeTypeHandle)+6f DynamicClass.WriteEntityChangeTrackerToXml(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.XmlObjectSerializerWriteContext, System.Runtime.Serialization.ClassDataContract)+31a System_Runtime_Serialization_ni!System.Runtime.Serialization.ClassDataContract.WriteXmlValue(System.Runtime.Serialization.XmlWriterDelegator, System.Object, System.Runtime.Serialization.XmlObjectSerializerWriteContext)+31 System_Runtime_Serialization_ni!System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(System.Runtime.Serialization.XmlWriterDelegator, System.Object, Boolean, Boolean, Int32, System. RuntimeTypeHandle)+6f...
...序列化就这样继续,然后...
...System_ServiceModel_ni!System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(System.ServiceModel.Channels.RequestContext, Boolean, System.ServiceModel.OperationContext)+7d7 System_ServiceModel_ni!System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(System.ServiceModel.Channels .RequestContext, System.ServiceModel.OperationContext)+1ff System_ServiceModel_ni!System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(System.IAsyncResult)+db System_ServiceModel_Internals_ni!System.Runtime.Fx+AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult)+32 System_ServiceModel_Internals_ni!System .Runtime.AsyncResult.Complete(Boolean)+19e System_ServiceModel_ni!System.ServiceModel.Channels.TransportDuplexSessionChannel+TryReceiveAsyncResult.OnReceive(System.IAsyncResult)+11d System_ServiceModel_Internals_ni!System。Runtime.Fx+AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult)+32 System_ServiceModel_Internals_ni!System.Runtime.AsyncResult.Complete(Boolean)+19e System_ServiceModel_ni!System.ServiceModel.Channels.SynchronizedMessageSource+ReceiveAsyncResult.OnReceiveComplete(System.Object)+82 System_ServiceModel_ni! System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(System.Object)+170 System_ServiceModel_ni!System.ServiceModel.Channels.SocketConnection.OnReceiveAsync(System.Object, System.Net.Sockets.SocketAsyncEventArgs)+fd System_ni!System.Net.Sockets。 SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError, Int32, System.Net.Sockets.SocketFlags)+bd5 System_ni!System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)+40 mscorlib_ni !System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)+96 [[GCFrame]] [[DebuggerU2MCatchHandlerFrame]] [[ContextTransitionFrame]] [[DebuggerU2MCatchHandlerFrame]]
全栈跟踪
System_Core_ni!System.Linq.Expressions.ConstantExpression.Make(System.Object, System.Type)+69 System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+ConstantTranslator.TypedTranslate(System.Data.Entity.Core.Objects. ELinq.ExpressionConverter, System.Linq.Expressions.ConstantExpression)+12d 0x000000dc
6cf0c5d0 clr!GetMetaDataPublicInterfaceFromInternal+3c494 System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(System.Linq.Expressions.Expression)+ae System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator+ContainsTranslator.TranslateContains(System.Data.Entity.Core.Objects.ELinq.ExpressionConverter, System.Linq.Expressions.Expression, System.Linq.Expressions.Expression)+46 System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator.TypedTranslate(System.Data.Entity.Core.Objects.ELinq.ExpressionConverter, System.Linq.Expressions.MethodCallExpression)+d3 System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+BinaryTranslator.TypedTranslate(System.Data.Entity.Core.Objects.ELinq.ExpressionConverter, System.Linq.Expressions.BinaryExpression)+132 System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(System.Linq.Expressions.Expression)+ae System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(System.Linq.Expressions.LambdaExpression, System.Data.Entity.Core.Common.CommandTrees.DbExpression)+7e System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator+OneLambdaTranslator.Translate(System.Data.Entity.Core.Objects.ELinq.ExpressionConverter, System.Linq.Expressions.MethodCallExpression, System.Data.Entity.Core.Common.CommandTrees.DbExpression ByRef, System.Data.Entity.Core.Common.CommandTrees.DbExpressionBinding ByRef, System.Data.Entity.Core.Common.CommandTrees.DbExpression ByRef)+eb System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator+OneLambdaTranslator.Translate(System.Data.Entity.Core.Objects.ELinq.ExpressionConverter, System.Linq.Expressions.MethodCallExpression)+3d System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator.TypedTranslate(System.Data.Entity.Core.Objects.ELinq.ExpressionConverter, System.Linq.Expressions.MethodCallExpression)+d3 System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(System.Linq.Expressions.Expression)+ae System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator+SelectTranslator.Translate(System.Data.Entity.Core.Objects.ELinq.ExpressionConverter, System.Linq.Expressions.MethodCallExpression)+65 System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator.TypedTranslate(System.Data.Entity.Core.Objects.ELinq.ExpressionConverter, System.Linq.Expressions.MethodCallExpression)+d3 System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.Convert()+a2 System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(System.Nullable
1)+128 System.Data.Entity.Core.Objects.ObjectQuery1+<>c__DisplayClass3[[System.__Canon, mscorlib]].<GetResults>b__2()+27 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[[System.__Canon, mscorlib]](System.Func
1, System.Data.Entity.Infrastructure.IDbExecutionStrategy, Boolean, Boolean)+110 [[ StubHelperFrame]] System.Data.Entity.Core.Objects.ObjectQuery1+<>c__DisplayClass3[[System.__Canon, mscorlib]].<GetResults>b__1()+ef System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[[System.__Canon, mscorlib]](System.Func
1)+3b System.Data.Entity.Core.Objects.ObjectQuery1[[System.__Canon, mscorlib]].GetResults(System.Nullable
1)+170 System.Data.Entity.Core.Objects.ObjectQuery1[[System.__Canon, mscorlib]].<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()+b System.Data.Entity.Internal.LazyEnumerator
1[[System.__Canon , mscorlib]].MoveNext()+32 mscorlib_ni!System.Collections.Generic.List1[[System.__Canon, mscorlib]]..ctor(System.Collections.Generic.IEnumerable
1)+218 System_Core_ni!System.Linq.Enumerable.ToList[System.__Canon, mscorlib]+50 **Repository.MethodName**(System.Collections.Generic.List1)+1626 ServiceName.MethodName (System.Collections.Generic. List`1)+18 DynamicClass.SyncInvoke MethodName(System.Object, System.Object[], System.Object[])+7a System_ServiceModel_ni!System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(System.Object, System.Object[], System.Object[] ByRef)+6a4 System_ServiceModel_ni!System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(System.ServiceModel.Dispatcher.MessageRpc ByRef)+505 System_ServiceModel_ni!System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(System.ServiceModel.Dispatcher.MessageRpc ByRef)+110 System_ServiceModel_ni!System。 ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(System.ServiceModel.Dispatcher.MessageRpc ByRef)+17b System_ServiceModel_ni!System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean)+17e System_ServiceModel_ni!System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(System.ServiceModel .Channels.RequestContext, Boolean, System.ServiceModel.OperationContext)+7d7 System_ServiceModel_ni!System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(System.ServiceModel.Channels.RequestContext, System.ServiceModel.OperationContext)+1ff System_ServiceModel_ni!System.ServiceModel.Dispatcher。 ChannelHandler.AsyncMessagePump(System.IAsyncResult)+db System_ServiceModel_Internals_ni!System.Runtime.Fx+AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult)+32 System_ServiceModel_Internals_ni!System.Runtime.AsyncResult.Complete(Boolean)+19e System_ServiceModel_ni!System.ServiceModel.Channels。 TransportDuplexSessionChannel+TryReceiveAsyncResult.OnReceive(System.IAsyncResult)+11d System_ServiceModel_Internals_ni!System.Runtime.Fx+AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult)+32 System_ServiceModel_Internals_ni!System。Runtime.AsyncResult.Complete(Boolean)+19e System_ServiceModel_ni!System.ServiceModel.Channels.SynchronizedMessageSource+ReceiveAsyncResult.OnReceiveComplete(System.Object)+82 System_ServiceModel_ni!System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(System.Object)+170 System_ServiceModel_ni! System.ServiceModel.Channels.SocketConnection.OnReceiveAsync(System.Object, System.Net.Sockets.SocketAsyncEventArgs)+fd System_ni!System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError, Int32, System.Net. Sockets.SocketFlags)+bd5 System_ni!System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)+40 mscorlib_ni!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading。NativeOverlapped*)+96 [[GCFrame]] [[DebuggerU2MCatchHandlerFrame]] [[ContextTransitionFrame]] [[DebuggerU2MCatchHandlerFrame]]
太多的数据也会导致这种情况吗?谢谢,