Symptom:
Hosting environment: Production
Content root path: D:\XXXXX
Now listening on: http://localhost:29127
Application started. Press Ctrl+C to shut down.
Process is terminated due to StackOverflowException.
The dotnet.exe runs for some time and then - all of the sudden - crashes. Sometimes it recovers, but sometimes it does not. In the latter case, I need to manually kick the IIS app to get it back.
This StackOverflow exception occurs when a response is written to the stream. The bottom part of the stack strace:
…
ServiceStack.Text.Common.WriteType`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteProperties(System.IO.TextWriter, System.Object)+59d
ServiceStack.Text.Common.WriteType`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteProperties(System.IO.TextWriter, System.Object)+59d
ServiceStack.Text.Common.WriteListsOfElements`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteGenericIList(System.IO.TextWriter, System.Collections.Generic.IList`1<System.__Canon>)+f9
ServiceStack.Text.Common.WriteType`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteProperties(System.IO.TextWriter, System.Object)+59d
ServiceStack.Text.Common.WriteType`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteProperties(System.IO.TextWriter, System.Object)+59d
ServiceStack.Text.Common.WriteListsOfElements`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteGenericIList(System.IO.TextWriter, System.Collections.Generic.IList`1<System.__Canon>)+f9
ServiceStack.Text.Common.WriteType`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteProperties(System.IO.TextWriter, System.Object)+59d
ServiceStack.Text.Common.WriteType`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteProperties(System.IO.TextWriter, System.Object)+59d
ServiceStack.Text.Common.WriteListsOfElements`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteGenericIList(System.IO.TextWriter, System.Collections.Generic.IList`1<System.__Canon>)+f9
ServiceStack.Text.Common.WriteType`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteProperties(System.IO.TextWriter, System.Object)+59d
ServiceStack.Text.Common.WriteType`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteProperties(System.IO.TextWriter, System.Object)+59d
ServiceStack.Text.Common.WriteListsOfElements`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteGenericIList(System.IO.TextWriter, System.Collections.Generic.IList`1<System.__Canon>)+f9
ServiceStack.Text.Common.WriteType`2[[System.__Canon, System.Private.CoreLib],[System.__Canon, System.Private.CoreLib]].WriteProperties(System.IO.TextWriter, System.Object)+59d**
ServiceStack.Text.JsonSerializer.SerializeToStream(System.Object, System.Type, System.IO.Stream)
ServiceStack.Text.JsonSerializer.SerializeToStream[[System.__Canon, System.Private.CoreLib]](System.__Canon, System.IO.Stream)
ServiceStack.HttpResponseExtensionsInternal.WriteToResponse(ServiceStack.Web.IResponse, System.Object, ServiceStack.Web.ResponseSerializerDelegate, ServiceStack.Web.IRequest, Byte[], Byte[])
ServiceStack.HttpResponseExtensionsInternal.WriteToResponse(ServiceStack.Web.IResponse, ServiceStack.Web.IRequest, System.Object, Byte[], Byte[])
ServiceStack.Host.RestHandler+<>c__DisplayClass13_0.<ProcessRequestAsync>b__0(System.Object)
ServiceStack.Host.Handlers.ServiceStackHandlerBase.HandleResponse(System.Object, System.Func`2<System.Object, System.Threading.Tasks.Task>, System.Func`2<System.Exception, System.Threading.Tasks.Task>)
ServiceStack.Host.RestHandler.ProcessRequestAsync(ServiceStack.Web.IRequest, ServiceStack.Web.IResponse, System.String)
ServiceStack.AppHostBase.ProcessRequest(Microsoft.AspNetCore.Http.HttpContext, System.Func`1<System.Threading.Tasks.Task>)
Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+<Invoke>d__6.MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+<Invoke>d__6, Microsoft.AspNetCore.Diagnostics]](<Invoke>d__6ByRef)
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware+<Invoke>d__8.MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware+<Invoke>d__8, Microsoft.AspNetCore.Server.IISIntegration]](<Invoke>d__8ByRef)
Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware+<Invoke>d__3.MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware+<Invoke>d__3, Microsoft.AspNetCore.Hosting]](<Invoke>d__3ByRef)
Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.Invoke(Microsoft.AspNetCore.Http.HttpContext)
Microsoft.AspNetCore.Hosting.Internal.HostingApplication.ProcessRequestAsync(Context)
Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Frame`1+<RequestProcessingAsync>d__2[[Microsoft.AspNetCore.Hosting.Internal.HostingApplication+Context, Microsoft.AspNetCore.Hosting]].MoveNext()
System_Private_CoreLib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+6e
System_Private_CoreLib_ni+61a5bb
Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.LoggingThreadPool.<RunAction>b__5_0(System.Object)
System_Private_CoreLib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+6e
System_Private_CoreLib_ni+747084
System_Private_CoreLib_ni+6176ac
coreclr!CallDescrWorkerInternal+83
coreclr!MethodDescCallSite::CallTargetWorker+14e
coreclr!QueueUserWorkItemManagedCallback+38
coreclr!SimpleComCallWrapper::InitNew+313
coreclr!SimpleComCallWrapper::InitNew+268
coreclr!SimpleComCallWrapper::InitNew+195
coreclr!SimpleComCallWrapper::InitNew+107
coreclr!ManagedPerAppDomainTPCount::DispatchWorkItem+8e
coreclr!ThreadpoolMgr::WorkerThreadStart+188
coreclr!Thread::intermediateThreadProc+8b
kernel32!BaseThreadInitThunk+1a
ntdll!RtlUserThreadStart+1d
The trace goes on with the Common.WriteType and Common.WriteListOfElements’2 for some time, before it quits and calls it a day. I have not been able to get more info than this, and I am basically scratching my head… Any ideas to get this sorted are more than welcome… There seems to be some recursive loop. Is there any possibility to get more info than this?