Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stackoverflow exception #139

Closed
Havunen opened this issue Jun 12, 2019 · 101 comments
Closed

Stackoverflow exception #139

Havunen opened this issue Jun 12, 2019 · 101 comments
Labels
bug Something isn't working
Milestone

Comments

@Havunen
Copy link
Contributor

Havunen commented Jun 12, 2019

Hi,

I have been investigating an issue where w3wp.exe process crashes under heavy load. I was finally able to get memory dump of crashing process and it seems to come from DryIoc.

image

Here are details of Thread 51.

Thread 51 - System ID 7224
Entry point   clr!Thread::intermediateThreadProc 
Create time   6/12/2019 8:24:29 PM 
Time spent in user mode   0 Days 00:00:00.250 
Time spent in kernel mode   0 Days 00:00:00.031 

This thread is not fully resolved and may or may not be a problem. Further analysis of these threads may be required.
The thread has evidence of .net exceptions on the stack. Check the Previous .NET Exceptions Report (Exceptions in all .NET Thread Stacks) to view more details of the associated exception  

.Net Call Stack

[[PrestubMethodFrame] (.)] DynamicClass.(ArrayClosure) 
DryIoc.Scope.TryGetOrAdd(ImTools.ImMap`1, Int32, DryIoc.CreateScopedValue, Int32)+f8 
DryIoc.Scope.GetOrAdd(Int32, DryIoc.CreateScopedValue, Int32)+67 
DynamicClass.(ArrayClosure)+d3e46 
DryIoc.Scope.TryGetOrAdd(ImTools.ImMap`1, Int32, DryIoc.CreateScopedValue, Int32)+f8 
DryIoc.Scope.GetOrAdd(Int32, DryIoc.CreateScopedValue, Int32)+67 
DynamicClass.(ArrayClosure, DryIoc.IResolverContext)+13af1 
DryIoc.Container.DryIoc.IResolver.Resolve(System.Type, System.Object, DryIoc.IfUnresolved, System.Type, DryIoc.Request, System.Object[])+37a 
DryIoc.Container.ResolveAndCacheFactoryDelegate(System.Type, DryIoc.IfUnresolved)+140 
Severa.Rest.API.DryIocControllerActivator.Create(System.Net.Http.HttpRequestMessage, System.Web.Http.Controllers.HttpControllerDescriptor, System.Type)+52 
System.Web.Http.Dispatcher.HttpControllerDispatcher+d__15.MoveNext()+12d 
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Dispatcher.HttpControllerDispatcher+d__15, System.Web.Http]](d__15 ByRef)+7a 
System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+83 
System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+64 
System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+257 
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31 
DryIoc.WebApi.RegisterRequestMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+29 
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31 
System.Web.Http.HttpServer+d__24.MoveNext()+1a0 
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.HttpServer+d__24, System.Web.Http]](d__24 ByRef)+7a 
System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+83 
System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+64 
System.Web.Http.Owin.HttpMessageHandlerAdapter+d__20.MoveNext()+25a 
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.Web.Http.Owin.HttpMessageHandlerAdapter+d__20, System.Web.Http.Owin]](d__20 ByRef)+80 
System.Web.Http.Owin.HttpMessageHandlerAdapter.InvokeCore(Microsoft.Owin.IOwinContext, Microsoft.Owin.IOwinRequest, Microsoft.Owin.IOwinResponse)+7b 
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+d__5[[System.__Canon, mscorlib]].MoveNext()+229 
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+d__5[[System.__Canon, mscorlib]], Microsoft.Owin.Security]](d__5 ByRef)+a4 
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1[[System.__Canon, mscorlib]].Invoke(Microsoft.Owin.IOwinContext)+9e 
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__7.MoveNext()+3d 
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__7, Microsoft.Owin.Host.SystemWeb]](d__7 ByRef)+80 
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.RunApp(System.Func`2,System.Threading.Tasks.Task>, System.Collections.Generic.IDictionary`2, System.Threading.Tasks.TaskCompletionSource`1, Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult)+80 
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent(System.Object, System.EventArgs, System.AsyncCallback, System.Object)+27a 
System.Web.HttpApplication+AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+182 
System.Web.HttpApplication+<>c__DisplayClass285_0.b__0()+25 
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep)+9b 
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)+83 
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)+74d 
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)+83 
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)+1e2 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+441 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13 
DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52 
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)+7e 
[[InlinedCallFrame] (System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion)] System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatusByRef) 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+504 
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13 
DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52 
[[ContextTransitionFrame]] 

Full Call Stack

clr!ExecutionManager::GetCodeMethodDesc+17    
clr!MethodTable::GetMethodDescForSlot+aa    
clr!MethodDesc::FindOrCreateAssociatedMethodDesc+14f    
clr!CEEInfo::getCallInfo+23dd    
clrjit!Compiler::impImportBlockCode+4116 [f:\dd\ndp\clr\src\jit\importer.cpp @ 13107]   f:\dd\ndp\clr\src\jit\importer.cpp @ 13107 
clrjit!Compiler::impImportBlock+7d [f:\dd\ndp\clr\src\jit\importer.cpp @ 16079]   f:\dd\ndp\clr\src\jit\importer.cpp @ 16079 
clrjit!Compiler::impImport+2f7 [f:\dd\ndp\clr\src\jit\importer.cpp @ 17163]   f:\dd\ndp\clr\src\jit\importer.cpp @ 17163 
clrjit!Compiler::compCompile+99 [f:\dd\ndp\clr\src\jit\compiler.cpp @ 4386 + c]   f:\dd\ndp\clr\src\jit\compiler.cpp @ 4386 + c 
clrjit!Compiler::compCompileHelper+2a7 [f:\dd\ndp\clr\src\jit\compiler.cpp @ 6025]   f:\dd\ndp\clr\src\jit\compiler.cpp @ 6025 
clrjit!Compiler::compCompile+24b [f:\dd\ndp\clr\src\jit\compiler.cpp @ 5359 + 1a]   f:\dd\ndp\clr\src\jit\compiler.cpp @ 5359 + 1a 
clrjit!jitNativeCode+26a [f:\dd\ndp\clr\src\jit\compiler.cpp @ 6666 + 50]   f:\dd\ndp\clr\src\jit\compiler.cpp @ 6666 + 50 
clrjit!<lambda_1e1cefc294d1d43a093c8e94a2fac4f7>::<helper_func_cdecl>+fc [f:\dd\ndp\clr\src\jit\flowgraph.cpp @ 22434]   f:\dd\ndp\clr\src\jit\flowgraph.cpp @ 22434 
clr!CEEInfo::runWithErrorTrap+47    
clrjit!Compiler::fgInvokeInlineeCompiler+165 [f:\dd\ndp\clr\src\jit\flowgraph.cpp @ 22448]   f:\dd\ndp\clr\src\jit\flowgraph.cpp @ 22448 
clrjit!Compiler::fgMorphCallInlineHelper+a9 [f:\dd\ndp\clr\src\jit\morph.cpp @ 7102]   f:\dd\ndp\clr\src\jit\morph.cpp @ 7102 
clrjit!Compiler::fgInline+1ae [f:\dd\ndp\clr\src\jit\flowgraph.cpp @ 21827 + 10]   f:\dd\ndp\clr\src\jit\flowgraph.cpp @ 21827 + 10 
clrjit!Compiler::fgMorph+85 [f:\dd\ndp\clr\src\jit\morph.cpp @ 18063]   f:\dd\ndp\clr\src\jit\morph.cpp @ 18063 
clrjit!Compiler::compCompile+1cb [f:\dd\ndp\clr\src\jit\compiler.cpp @ 4480]   f:\dd\ndp\clr\src\jit\compiler.cpp @ 4480 
clrjit!Compiler::compCompileHelper+2a7 [f:\dd\ndp\clr\src\jit\compiler.cpp @ 6025]   f:\dd\ndp\clr\src\jit\compiler.cpp @ 6025 
clrjit!Compiler::compCompile+24b [f:\dd\ndp\clr\src\jit\compiler.cpp @ 5359 + 1a]   f:\dd\ndp\clr\src\jit\compiler.cpp @ 5359 + 1a 
clrjit!jitNativeCode+26a [f:\dd\ndp\clr\src\jit\compiler.cpp @ 6666 + 50]   f:\dd\ndp\clr\src\jit\compiler.cpp @ 6666 + 50 
clrjit!CILJit::compileMethod+a2 [f:\dd\ndp\clr\src\jit\ee_il_dll.cpp @ 315]   f:\dd\ndp\clr\src\jit\ee_il_dll.cpp @ 315 
clr!invokeCompileMethodHelper+ce    
clr!invokeCompileMethod+97    
clr!CallCompileMethodWithSEHWrapper+52    
clr!UnsafeJitFunction+7ea    
clr!MethodDesc::MakeJitWorker+498    
clr!MethodDesc::DoPrestub+94c    
clr!PreStubWorker+3cc    
clr!ThePreStub+55    
DryIoc.Scope.TryGetOrAdd(ImTools.ImMap`1<System.Object>, Int32, DryIoc.CreateScopedValue, Int32)+f8    
DryIoc.Scope.GetOrAdd(Int32, DryIoc.CreateScopedValue, Int32)+67    
DynamicClass.(ArrayClosure)+d3e46    
DryIoc.Scope.TryGetOrAdd(ImTools.ImMap`1<System.Object>, Int32, DryIoc.CreateScopedValue, Int32)+f8    
DryIoc.Scope.GetOrAdd(Int32, DryIoc.CreateScopedValue, Int32)+67    
DynamicClass.(ArrayClosure, DryIoc.IResolverContext)+13af1    
DryIoc.Container.DryIoc.IResolver.Resolve(System.Type, System.Object, DryIoc.IfUnresolved, System.Type, DryIoc.Request, System.Object[])+37a    
DryIoc.Container.ResolveAndCacheFactoryDelegate(System.Type, DryIoc.IfUnresolved)+140    
Severa.Rest.API.DryIocControllerActivator.Create(System.Net.Http.HttpRequestMessage, System.Web.Http.Controllers.HttpControllerDescriptor, System.Type)+52    
System.Web.Http.Dispatcher.HttpControllerDispatcher+<SendAsync>d__15.MoveNext()+12d    
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Dispatcher.HttpControllerDispatcher+<SendAsync>d__15, System.Web.Http]](<SendAsync>d__15 ByRef)+7a    
System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+83    
System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+64    
System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+257    
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31    
DryIoc.WebApi.RegisterRequestMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+29    
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31    
System.Web.Http.HttpServer+<SendAsync>d__24.MoveNext()+1a0    
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.HttpServer+<SendAsync>d__24, System.Web.Http]](<SendAsync>d__24 ByRef)+7a    
System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+83    
System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+64    
System.Web.Http.Owin.HttpMessageHandlerAdapter+<InvokeCore>d__20.MoveNext()+25a    
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.Web.Http.Owin.HttpMessageHandlerAdapter+<InvokeCore>d__20, System.Web.Http.Owin]](<InvokeCore>d__20 ByRef)+80    
System.Web.Http.Owin.HttpMessageHandlerAdapter.InvokeCore(Microsoft.Owin.IOwinContext, Microsoft.Owin.IOwinRequest, Microsoft.Owin.IOwinResponse)+7b    
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+<Invoke>d__5[[System.__Canon, mscorlib]].MoveNext()+229    
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+<Invoke>d__5[[System.__Canon, mscorlib]], Microsoft.Owin.Security]](<Invoke>d__5<System.__Canon> ByRef)+a4    
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1[[System.__Canon, mscorlib]].Invoke(Microsoft.Owin.IOwinContext)+9e    
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+<RunApp>d__7.MoveNext()+3d    
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+<RunApp>d__7, Microsoft.Owin.Host.SystemWeb]](<RunApp>d__7 ByRef)+80    
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.RunApp(System.Func`2<System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.Threading.Tasks.Task>, System.Collections.Generic.IDictionary`2<System.String,System.Object>, System.Threading.Tasks.TaskCompletionSource`1<System.Object>, Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult)+80    
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent(System.Object, System.EventArgs, System.AsyncCallback, System.Object)+27a    
System.Web.HttpApplication+AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+182    
System.Web.HttpApplication+<>c__DisplayClass285_0.<ExecuteStepImpl>b__0()+25    
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep)+9b    
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)+83    
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)+74d    
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)+83    
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)+1e2    
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+441    
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13    
DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52    
clr!UMThunkStub+6e    
webengine4!W3_MGD_HANDLER::ProcessNotification+8e    
webengine4!W3_MGD_HANDLER::DoWork+3a5    
webengine4!RequestDoWork+3fc    
webengine4!CMgdEngHttpModule::OnAcquireRequestState+1f    
iiscore!NOTIFICATION_CONTEXT::RequestDoWork+b9    
iiscore!NOTIFICATION_CONTEXT::CallModulesInternal+19c    
iiscore!NOTIFICATION_CONTEXT::CallModules+36    
iiscore!NOTIFICATION_MAIN::DoWork+1cf    
iiscore!W3_CONTEXT_BASE::IndicateCompletion+d6    
webengine4!W3_MGD_HANDLER::IndicateCompletion+5d    
webengine4!MgdIndicateCompletion+22    
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)+7e    
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+504    
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13    
DomainNeutralILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52    
clr!UM2MThunk_WrapperHelper+43    
clr!UM2MThunk_Wrapper+60    
clr!Thread::DoADCallBack+13d    
clr!UM2MDoADCallBack+b3    
clr!UMThunkStub+26d    
webengine4!W3_MGD_HANDLER::ProcessNotification+8e    
webengine4!ProcessNotificationCallback+42    
clr!UnManagedPerAppDomainTPCount::DispatchWorkItem+1bc    
clr!ThreadpoolMgr::ExecuteWorkRequest+64    
clr!ThreadpoolMgr::WorkerThreadStart+f5    
clr!Thread::intermediateThreadProc+86    
kernel32!BaseThreadInitThunk+14    
ntdll!RtlUserThreadStart+21 
Windows Server 2016 - 14393
Processor Type X64
Process Bitness  64-Bit
CLR version = 4.7.3394.0

This is blocker for us to start using DryIoc. This is really strange error, it does not seem to happen in Debug mode and performance seems better in Debug. When built in Release this error occurs and CPU spikes way more. Maybe it has something to do with Jit compiler

@dadhi
Copy link
Owner

dadhi commented Jun 12, 2019

Hmm, thanks for finding. Could you check what happens if you set the rule:

new Container(rules => rules.WithoutFastExpressionCompiler())?

@Havunen
Copy link
Contributor Author

Havunen commented Jun 13, 2019

Hey! Thanks I did some testing with and without fastExpressionCompiler and it seems the issue is there.

This is the configuration we used by default.

Dim container = New Container(
	Function(rules)
		Return rules.With(FactoryMethod.ConstructorWithResolvableArguments)
	End Function
).WithWebApi(config)

Then to disable fast expression compiler we used this code:

Dim container = New Container(
	Function(rules)
		Return rules.WithoutFastExpressionCompiler().With(FactoryMethod.ConstructorWithResolvableArguments)
	End Function
).WithWebApi(config)

Here are the results:

Thread count WithFastExpressionCompiler WithoutFastExpressionCompiler
60 Crash after 2mins Pass
500 Crash after ~15secs Pass

We also noticed CPU usage is way better without fast expression compiler, maybe its related to the bug or something else. Anyway this workaround works for us. Thanks for your help

@dadhi
Copy link
Owner

dadhi commented Jun 13, 2019

..Interesting, thanks for the info. Will check from here.

@dadhi
Copy link
Owner

dadhi commented Jun 17, 2019

Hi @Havunen

Could you help to verify something?

Replace .WithoutFastExpressionCompiler() with .WithDependencyDepthToSplitObjectGraph(10).

@Havunen
Copy link
Contributor Author

Havunen commented Jun 17, 2019

I did quick test and it seems .WithDependencyDepthToSplitObjectGraph(10) did not fix the issue.

@dadhi
Copy link
Owner

dadhi commented Jun 17, 2019

Thanks for checking.

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

Today this issue started happening in our development server, even without fast expression compiler.

new Container((rules) => 
    rules.WithoutFastExpressionCompiler().With(FactoryMethod.ConstructorWithResolvableArguments)
);

Here is crash dump:

  Arg 1 Arg 2 Arg 3 Arg 4 Source
DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure)+5 0000001`02fdd628 00007fe`9b1e6c18 0000000`00000000 00007fe`99c56417  
DryIoc.Scope.TryGetOrAdd(ImTools.ImMap`1<System.Object>, Int32, DryIoc.CreateScopedValue, Int32)+b9 0000001`02fdd400 0000002`002c8d98 0000000`000000b1 0000002`05ff93e0  
DryIoc.Scope.GetOrAdd(Int32, DryIoc.CreateScopedValue, Int32)+4f 0000000`00000003 0000002`002c8d98 0000001`02fdd628 00007fe`9c9fb580  
DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, DryIoc.IResolverContext)+125 0000002`003faae0 00007fe`9b1e6cdc 00007fe`99c65d45 00007fe`f9361405  
DryIoc.Container.DryIoc.IResolver.Resolve(System.Type, System.Object, DryIoc.IfUnresolved, System.Type, DryIoc.Request, System.Object[])+245 0000001`056a7ff8 00007fe`9b5d914c 0000001`056e1408 00007fe`9d53bd98  
DryIoc.Container.ResolveAndCacheFactoryDelegate(System.Type, DryIoc.IfUnresolved)+103 0000002`00185c40 00007fe`9bcbebac 0000001`056f2a90 0000001`056dfe28  
System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(System.Net.Http.HttpRequestMessage, System.Type, System.Func`1<System.Web.Http.Controllers.IHttpController> ByRef)+26 0000001`056dfe28 0000001`002c5798 0000001`056dff60 00007fe`9d0fe2e7  
System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(System.Net.Http.HttpRequestMessage, System.Web.Http.Controllers.HttpControllerDescriptor, System.Type)+5c 00007fe`99cd0bb8 00007fe`99c65c69 0000000`00000000 0000002`002ce480  
System.Web.Http.Dispatcher.HttpControllerDispatcher+d__15.MoveNext()+11d 0000000`159ddf78 0000001`056e7098 0000000`159ddf30 0000001`056b7630  
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Dispatcher.HttpControllerDispatcher+d__15, System.Web.Http]](d__15 ByRef)+6c 0000001`056dfe28 0000001`056e71a8 0000002`00417e58 00007fe`9d0fcd96  
System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+7d 0000001`056f2c08 0000001`056dff60 0000000`159ddfe0 0000001`056b7630  
System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+52 0000002`00187270 0000002`002f85a0 0000001`056dff60 00007fe`9d0fb650  
System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+213 0000001`056a7ff8 00007fe`99c5dfe5 00007fe`9d53bd28 0000001`056dfe28  
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31 0000001`056dff60 00007fe`9d0fb650 0000000`00000000 00007fe`99c65c69  
DryIoc.WebApi.RegisterRequestMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+29 0000001`056e10a8 00007fe`9d53b968 0000002`004e2d90 00007fe`9d0fb528  
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31 0000001`056e1180 00007fe`9d53b968 0000001`056dfe28 0000000`159de2c8  
System.Web.Http.HttpServer.<>n__0(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+9 0000000`159de200 00007fe`99c65c69 0000001`056e0e30 0000001`056dff60  
System.Web.Http.HttpServer+d__24.MoveNext()+16f 0000000`159de2c8 0000001`056dfbb0 0000000`00000000 0000001`056a0510  
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.HttpServer+d__24, System.Web.Http]](d__24 ByRef)+6c 0000000`159de3d8 00007fe`9a0f7dc8 0000000`159de358 00007fe`99c65c69  
System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+7d 0000000`00000001 00007fe`9d0fa11e 0000001`00866400 0000001`056b7398  
System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+52 0000000`159de430 00007fe`99c66a02 0000000`00000000 00007fe`99c65c69  
System.Web.Http.Owin.HttpMessageHandlerAdapter+d__20.MoveNext()+253 0000000`159de4f0 00007fe`9d0f5fdf 0000001`056a0498 00007fe`9b1dfa5d  
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.Web.Http.Owin.HttpMessageHandlerAdapter+d__20, System.Web.Http.Owin]](d__20 ByRef)+6c 0000000`00000000 0000000`00000000 0000000`00000000 0000000`00000000  
System.Web.Http.Owin.HttpMessageHandlerAdapter.InvokeCore(Microsoft.Owin.IOwinContext, Microsoft.Owin.IOwinRequest, Microsoft.Owin.IOwinResponse)+6b 00007fe`f92127ce 00007fe`99c65c69 0000000`159de3f8 0000001`0004b4d0  
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+d__5[[System.__Canon, mscorlib]].MoveNext()+222 0000000`159de6e8 0000000`00000000 0000001`056dedc8 00007fe`9a9fe270  
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+d__5[[System.__Canon, mscorlib]], Microsoft.Owin.Security]](d__5<System.__Canon> ByRef)+96 0000002`000b89e8 0000001`056dfbb0 00007fe`9d0bf9e9 00007fe`9d0bf7ea  
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1[[System.__Canon, mscorlib]].Invoke(Microsoft.Owin.IOwinContext)+8e 0000001`056a0498 00007fe`9b1dfa5d 0000001`056debc0 0000002`004eee18  
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__7.MoveNext()+3c 0000000`159de880 0000002`004eee18 0000000`159de840 0000001`056a50a0  
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__7, Microsoft.Owin.Host.SystemWeb]](d__7 ByRef)+6c 0000001`056a7ff8 0000002`002c3770 00007fe`9d0be9a3 00007fe`9d0be682  
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.RunApp(System.Func2<System.Collections.Generic.IDictionary2<System.String,System.Object>,System.Threading.Tasks.Task>, System.Collections.Generic.IDictionary2<System.String,System.Object>, System.Threading.Tasks.TaskCompletionSource1<System.Object>, Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult)+70 0000000`159de970 00007fe`ea694cba 0000001`056b7630 0000000`0da3fa20  
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent(System.Object, System.EventArgs, System.AsyncCallback, System.Object)+233 0000000`00000005 00007fe`9d0b313a 0000000`0da3faa8 00007fe`9b2a6795  
System.Web.HttpApplication+AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+ef 0000000`00000000 0000001`056dfa38 0000001`056dfa38 0000002`00b99328  
System.Web.HttpApplication+<>c__DisplayClass285_0.b__0()+25 0000001`056dfa78 00007fe`9a434db8 0000000`159de9c0 00007fe`9d0a7255  
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep)+a6 0000001`055d15c0 00007fe`9d0b304f 0000000`00000000 00007fe`9d0b3231  
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)+83 0000002`00b95f10 0000002`00b99fe8 0000000`159deb48 0000000`00000000  
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)+4e3 0000002`00b9ad18 00007fe`9d0acd01 0000001`056df348 0000000`159dec30  
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)+70 0000000`159dec40 00007fe`f91a50f9 0000000`159dec18 0000000`00000000  
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)+177 0000000`fffd3e60 0000001`02fceb78 0000001`02fcf0a8 0000000`00000000  
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+33a 0000000`00000018 0000000`1ce8d930 0000000`00000010 0000000`00ab2c70  
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13 00050b4`0358798d 0000000`159def50 00007fe`ea693060 00007fe`e3071d38  
DomainBoundILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52 0000000`00000000 0000000`00000000 0000000`00000000 0000000`00000000  
clr!UMThunkStub+6e 0000000`1ce8d930 00007fe`00000000 0000000`1ce8dd60 0000000`1ce8dddc  
webengine4!W3_MGD_HANDLER::ProcessNotification+8e 00007fe`00000000 00007fe`ea695f40 0000000`1ce8d930 00007fe`ea699a22  
webengine4!W3_MGD_HANDLER::DoWork+3a5 00007fe`ea695f40 0000000`00000020 0000000`1ce8d930 0000000`00000000  
webengine4!RequestDoWork+3fc 0000000`00000001 0000000`0d30b5c8 0000000`011a9b38 0000000`0da3fa20  
webengine4!CMgdEngHttpModule::OnAcquireRequestState+1f 0000000`00000000 0000000`011a9cd8 0000000`00000000 0000000`1cbea7f0  
iiscore!NOTIFICATION_CONTEXT::RequestDoWork+2a8 0000000`0da3fa28 0000002`000b89e8 0000000`159df0d0 0000002`000b89e8  
iiscore!NOTIFICATION_CONTEXT::CallModulesInternal+174 0000001`056a5a10 0000000`0da3fa20 0000000`0da3fa28 0000000`00000000  
iiscore!NOTIFICATION_CONTEXT::CallModules+25 0000000`159df220 00007fe`f91e6bb9 0000001`056a5c78 0000000`00000000  
iiscore!W3_CONTEXT::DoWork+18f 0000000`1ce8db90 0000000`1ce8db98 0000000`1ce8dc40 0000000`1ce8dc48  
iiscore!W3_CONTEXT::IndicateCompletion+8c 0000000`159df680 0000000`00000000 00007fe`ea69a790 0000000`00000000  
webengine4!W3_MGD_HANDLER::IndicateCompletion+5d 0000000`159df790 0000000`159df790 0000000`159df758 00007fe`9d0a7255  
webengine4!MgdIndicateCompletion+22 0000001`055d2288 00007fe`9d0acd01 0000000`159df5c0 0007cbd`16d67245  
DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)+7e 0000000`fffd3e60 0000001`055d15c0 0000000`159df760 0000000`1cbea7f0  
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+3e2 0000000`00000000 0000000`1ce8d930 0000000`00000000 0000000`00000000  
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13 0000000`00000000 0000000`1cbea7f0 0000000`00000000 0000000`00000000  
DomainBoundILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52 0000000`00000000 00007fe`00000001 0000000`02933501 00007fe`f91aa568  
clr!UM2MThunk_WrapperHelper+43 0000000`00000000 00007fe`f91a5c75 0000000`00000000 00007fe`f91aa2b0  
clr!UM2MThunk_Wrapper+60 0000000`159dfa08 0000000`00000000 0000000`1cbea7f0 00007fe`f91a67a7  
clr!Thread::DoADCallBack+13d 0000000`159dfb01 0000002`00000002 00050b4`03586e9d 0000000`159dfb40  
clr!UM2MDoADCallBack+b3 0000000`092ab590 0000000`00000000 0000000`0000000b 0000000`00000000  
clr!UMThunkStub+26d 0000000`00000000 0000000`1ce8d930 0000000`0000000b 0000000`00000004  
webengine4!W3_MGD_HANDLER::ProcessNotification+8e 0000000`00000004 0000000`1ce8d930 00007fe`f9ae44b0 0000000`159dfde0  
webengine4!ProcessNotificationCallback+42 0000000`1ce8d930 00007fe`e3071750 00007fe`f9ae44b0 0000000`00000000  
clr!UnManagedPerAppDomainTPCount::DispatchWorkItem+1bc 00007fe`f91a97f0 0000000`159dfd00 0000000`159dfd01 0000000`001f4144  
clr!ThreadpoolMgr::ExecuteWorkRequest+64 0020002`000c000d 0000000`00000001 0000000`1cbea7f0 0000000`1cbea7f0  
clr!ThreadpoolMgr::WorkerThreadStart+f5 0000000`00000000 0000000`00000001 0000000`00000001 0000000`00000409  
clr!Thread::intermediateThreadProc+86 0000000`00000000 0000000`00000000 0000000`00000000 0000000`00000000  
kernel32!BaseThreadInitThunk+d 0000000`00000000 0000000`00000000 0000000`00000000 0000000`00000000  
ntdll!RtlUserThreadStart+1d

.Net callstack

DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure)+5
DryIoc.Scope.TryGetOrAdd(ImTools.ImMap`1, Int32, DryIoc.CreateScopedValue, Int32)+b9
DryIoc.Scope.GetOrAdd(Int32, DryIoc.CreateScopedValue, Int32)+4f
DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, DryIoc.IResolverContext)+125
DryIoc.Container.DryIoc.IResolver.Resolve(System.Type, System.Object, DryIoc.IfUnresolved, System.Type, DryIoc.Request, System.Object[])+245
DryIoc.Container.ResolveAndCacheFactoryDelegate(System.Type, DryIoc.IfUnresolved)+103
System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(System.Net.Http.HttpRequestMessage, System.Type, System.Func`1 ByRef)+26
System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(System.Net.Http.HttpRequestMessage, System.Web.Http.Controllers.HttpControllerDescriptor, System.Type)+5c
System.Web.Http.Dispatcher.HttpControllerDispatcher+d__15.MoveNext()+11d
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.Dispatcher.HttpControllerDispatcher+d__15, System.Web.Http]](d__15 ByRef)+6c
System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+7d
System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+52
System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+213
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31
DryIoc.WebApi.RegisterRequestMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+29
System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+31
System.Web.Http.HttpServer.<>n__0(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+9
System.Web.Http.HttpServer+d__24.MoveNext()+16f
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, mscorlib]].Start[[System.Web.Http.HttpServer+d__24, System.Web.Http]](d__24 ByRef)+6c
System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+7d
System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)+52
System.Web.Http.Owin.HttpMessageHandlerAdapter+d__20.MoveNext()+253
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.Web.Http.Owin.HttpMessageHandlerAdapter+d__20, System.Web.Http.Owin]](d__20 ByRef)+6c
System.Web.Http.Owin.HttpMessageHandlerAdapter.InvokeCore(Microsoft.Owin.IOwinContext, Microsoft.Owin.IOwinRequest, Microsoft.Owin.IOwinResponse)+6b
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+d__5[[System.__Canon, mscorlib]].MoveNext()+222
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1+d__5[[System.__Canon, mscorlib]], Microsoft.Owin.Security]](d__5 ByRef)+96
Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1[[System.__Canon, mscorlib]].Invoke(Microsoft.Owin.IOwinContext)+8e
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__7.MoveNext()+3c
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage+d__7, Microsoft.Owin.Host.SystemWeb]](d__7 ByRef)+6c
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.RunApp(System.Func`2,System.Threading.Tasks.Task>, System.Collections.Generic.IDictionary`2, System.Threading.Tasks.TaskCompletionSource`1, Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult)+70
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.BeginEvent(System.Object, System.EventArgs, System.AsyncCallback, System.Object)+233
System.Web.HttpApplication+AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+ef
System.Web.HttpApplication+<>c__DisplayClass285_0.b__0()+25
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep)+a6
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)+83
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)+4e3
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)+70
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)+177
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+33a
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13
DomainBoundILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52
DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)+7e
[[InlinedCallFrame] (System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion)] System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatusByRef)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)+3e2
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)+13
DomainBoundILStubClass.IL_STUB_ReversePInvoke(Int64, Int64, Int64, Int32)+52
[[ContextTransitionFrame]]

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

I managed to hit debugger on this stack overflow exception. I will try to add details on this thread to help getting it fixed

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

Inside TryGetOrAdd both items variables. Are {Empty} Height 0, Key 0, they are not equal so they are different objects.

Parameters:
id 179
createValue has 165 items
by inspecting createValue values I can see there is one type 2 times "ContextService", everything else seems to be there once.

Callstack starts from RegisterRequestMessageHandler cancellationToken IsCancellationRequested = False

On a side note, I had breakpoint on this line in container.cs
https://github.com/dadhi/DryIoc/blob/master/src/DryIoc/Container.cs#L9320
and it never went there. So it never found any type from _items property during thousands and thousands of requests / resolves

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

It seems like createValue() returned null

item = createValue(); // item = null

but I'm not sure if thats due to invalid state of debugger or if it actually happened

@Havunen Havunen changed the title Stackoverflow exception, only in Release build Stackoverflow exception Jun 25, 2019
@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

It seems like stackoverflow exception happens inside createValue

@dadhi
Copy link
Owner

dadhi commented Jun 25, 2019

Strange, maybe just maybe we have a recursive dependency here..
Anyway thanks for the additional info. I am currently sitting there in separate branch. Maybe will have some idea later.

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

I debugged this further and realized its cycling between TryInterpret and TryInterpretMany always returning true and its going into NewExpression branch. I started tracking changes and noticed additional decorators were added quite same time this stackoverflow exception started occuring. I believe it has something to do with dependencies of decorators

@dadhi
Copy link
Owner

dadhi commented Jun 25, 2019

Ok, this is pretty close!

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

Yeah commenting out decorator registration fixes the issue. I need to investigate further why it breaks it.

@dadhi
Copy link
Owner

dadhi commented Jun 25, 2019

Could you try another option to decrease the number of culprits: .WithoutDependencyDepthToSplitObjectGraph() ?

Assuming that your object graph is deeper than 20 levels.

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

Thanks for the idea, but it didn't work :/

Its still crashing

@dadhi
Copy link
Owner

dadhi commented Jun 25, 2019

Actually it is good to know..

So we need to look into GetDecoratorExpressionOrDefault which tries hard to find if decorator was already applied so to skip it. But likely it fails in your case. Generics and possible Wrappers make the work harder. Reuse should not be an issue but I may be wrong here.

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

It feels like there is some sort of pattern when this happens. Looks like GC hits and then quickly after that it crashes the application pool. Not sure...

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

Or maybe GC is just trying to clean the stackoverflow situation

@Havunen
Copy link
Contributor Author

Havunen commented Jun 25, 2019

I tried moving disposable handling inside the lock but that didn't matter

@Havunen
Copy link
Contributor Author

Havunen commented Jun 26, 2019

It looks like making all decorators singleton fixed the issue.
container.Register(Of IUserRepository,UserRepository)(setup:=Setup.Decorator, reuse := Reuse.Singleton)

We had not defined Reuse in decorators previously

@dadhi
Copy link
Owner

dadhi commented Jun 26, 2019

There are some other options for Decorator registration to try:

setup: Setup.DecoratorOf<T>(useDecorateeReuse: true)

@Havunen
Copy link
Contributor Author

Havunen commented Jun 26, 2019

I tried with singleton decorators and it still fails if I dont add WithoutFastExpressionCompiler option

@dadhi
Copy link
Owner

dadhi commented Jun 26, 2019

Ok, good to know as well.

@Havunen
Copy link
Contributor Author

Havunen commented Jul 1, 2019

I'm working on test case to reproduce this issue, I'm also trying to reproduce #137 same time. This is slow progress it will be huge app...

@dadhi
Copy link
Owner

dadhi commented Jul 1, 2019

Thank you.

@Havunen
Copy link
Contributor Author

Havunen commented Jul 3, 2019

I'm traveling for a week. I will get back to this when I'm back home.

@Havunen
Copy link
Contributor Author

Havunen commented Aug 19, 2019

Opened PR #162 to reduce this issue, but it will not fix this it only makes it less likely to happen. One might have even larger expression tree than what is in LoadTest.

@dadhi
Copy link
Owner

dadhi commented Aug 21, 2019

I have fixed Rules.WithDependencyDepthToSplitObjectGraph(5) to work with master LoadTest.
The v4.1.0-preview-01 is out. It did not included any FEC opcodes reduction yet.
I just wanted to publish a baseline version with all the fixes so far. Test it a bit in a public.
Then incorporate the current wip FEC improvements.

@alexandre-machado
Copy link

Hi

I think I have a problem related to this same exception
image
apparently the exception will be throw after the looping into DryIoc.Resolve

@dadhi
Copy link
Owner

dadhi commented Sep 9, 2019

Nope, seems like a different thing, cause it is inside the Interpret call and not inside the compiled delegate.

Did you try v4.1 preview packages?
What is your sample setup?

@alexandre-machado
Copy link

I use v4.0.7

            var container = new Container(rules => rules
                .WithoutThrowOnRegisteringDisposableTransient()
                .WithTrackingDisposableTransients()
                .WithAutoConcreteTypeResolution())
                .WithMvc(
                controllerAssemblies: new[] { Assembly.GetExecutingAssembly() },
                throwIfUnresolved: type => Debugger.IsAttached && type.Name.EndsWith("Controller"));

            container.Register<ILogger, LogWrapper>();
            container.Register<IAppConfig, AppConfig>(Reuse.Singleton);
            container.Register<IEmailService, EmailService>();
            container.Register<IHelperService, HelperService>();
            container.Register<IBankFileConverter, BankFileConverter>();

            new AllModules(container);

I will try the preview

@alexandre-machado
Copy link

using v4 preview 2 the exception took longer to be thrown

image

@dadhi
Copy link
Owner

dadhi commented Sep 9, 2019

Hmm, not funny. Thanks for the code. Will check later.

Just for experiment, could you try to add this to setup:

.WithDependencyDepthToSplitObjectGraph(5);

Btw, you don't need .WithoutThrow for transient disposables if you have .WithTracking...

Also, do you really need AutoConcreteTypeResolution? it is kind off fragile auto-magic thingy and may hide the registration problems. Just asking.

@Havunen
Copy link
Contributor Author

Havunen commented Sep 10, 2019

@alexandre-machado Have you tried WithoutFastExpressionCompiler() its needed because root cause of this bug is not fixed in FEC

Leszek-Kowalski pushed a commit to Leszek-Kowalski/DryIoc that referenced this issue Oct 11, 2019
updated copyright dates for DryIoc.Web package
Leszek-Kowalski pushed a commit to Leszek-Kowalski/DryIoc that referenced this issue Oct 11, 2019
Leszek-Kowalski pushed a commit to Leszek-Kowalski/DryIoc that referenced this issue Oct 11, 2019
fixed dadhi#139 LoadTest downgared to 2.5 min for 4th test
@Havunen
Copy link
Contributor Author

Havunen commented Oct 17, 2019

Has there been any progress with this issue? Its taking quite long time to get resolved. @dadhi Are you planning to split the stack or do you have some other strategy in mind?

@dadhi
Copy link
Owner

dadhi commented Oct 17, 2019

@Havunen Are you still having SO?

@Havunen
Copy link
Contributor Author

Havunen commented Oct 21, 2019

@dadhi I think SO still happens if FEC is used. We are currently using withoutFastExpressionCompiler setting to workaround the problem.

@dadhi
Copy link
Owner

dadhi commented Oct 21, 2019

@Havunen Just to be fully clear, and you are using 4.1 preview?

@Havunen
Copy link
Contributor Author

Havunen commented Oct 21, 2019

Yeah, we are using DryIoc 4.1.0-preview2

@dadhi
Copy link
Owner

dadhi commented Oct 21, 2019

Will try to use the approach from #176 and decrease the default split level

@dadhi
Copy link
Owner

dadhi commented Jan 5, 2020

Hi @Havunen

Here are the latest results with the released https://www.nuget.org/packages/DryIoc.dll/4.1.0-preview-04

* Fix results:
* - singletonDecorators: true                                         - 00:00:33.65
* - singletonDecorators: false                                        - 00:01:04.08
* - WithUseDecorateeReuseForDecorators and singletonDecorators: false - 00:00:42.31

so I am considering the initial issue closed.
Let's tackle the remaining things if any separately - likely for the new version.
I will give this preview a day or two and will release it as a stable thing.

Btw, check the new benchmarks in readme... this release is pushing really hard and maturity is higher as well

Thanks for all the work! Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants