Skip to content

MapSignalR hangs in the creation of the Performance Counters #3414

@corneliutusnea

Description

@corneliutusnea

Hi,
With the 2.2.0 build I started to have a problem in the app.MapSignalR() which it gets stuck in creating the Performance Counters. It's hard to reproduce but I get it about 3-4 times a day.

This is the callstack:

    System.dll!System.Diagnostics.PerformanceCounterLib.GetPerformanceCounterLib(string machineName, System.Globalization.CultureInfo culture)  Unknown
    System.dll!System.Diagnostics.PerformanceCounterLib.IsCustomCategory(string machine, string category)   Unknown
    System.dll!System.Diagnostics.PerformanceCounter.InitializeImpl()   Unknown
>   System.dll!System.Diagnostics.PerformanceCounter.PerformanceCounter(string categoryName, string counterName, string instanceName, bool readOnly)    Unknown
    Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.Infrastructure.PerformanceCounterManager.LoadCounter(string categoryName, string counterName, string instanceName, bool isReadOnly)  Unknown
    Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.Infrastructure.PerformanceCounterManager.SetCounterProperties()  Unknown
    Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.Infrastructure.PerformanceCounterManager.Initialize(string instanceName, System.Threading.CancellationToken hostShutdownToken)   Unknown
    Microsoft.AspNet.SignalR.Core.dll!Microsoft.AspNet.SignalR.Hosting.HostDependencyResolverExtensions.InitializeHost(Microsoft.AspNet.SignalR.IDependencyResolver resolver, string instanceName, System.Threading.CancellationToken hostShutdownToken)    Unknown
    Microsoft.AspNet.SignalR.Core.dll!Owin.OwinExtensions.UseSignalRMiddleware<Microsoft.AspNet.SignalR.Owin.Middleware.HubDispatcherMiddleware>(Owin.IAppBuilder builder, object[] args)   Unknown
    Microsoft.AspNet.SignalR.Core.dll!Owin.OwinExtensions.MapSignalR.AnonymousMethod__0(Owin.IAppBuilder subApp)    Unknown
    Microsoft.Owin.dll!Owin.MapExtensions.Map(Owin.IAppBuilder app, Microsoft.Owin.PathString pathMatch, System.Action<Owin.IAppBuilder> configuration) Unknown
    Microsoft.Owin.dll!Owin.MapExtensions.Map(Owin.IAppBuilder app, string pathMatch, System.Action<Owin.IAppBuilder> configuration)    Unknown
    Microsoft.AspNet.SignalR.Core.dll!Owin.OwinExtensions.MapSignalR(Owin.IAppBuilder builder, string path, Microsoft.AspNet.SignalR.HubConfiguration configuration)    Unknown
    Microsoft.AspNet.SignalR.Core.dll!Owin.OwinExtensions.MapSignalR(Owin.IAppBuilder builder)  Unknown
    SnowSparkle.OneSaas.dll!SnowSparkle.OneSaas.SignalRConfig.Configuration(Owin.IAppBuilder app) Line 22   C#
    [Native to Managed Transition]  
    Microsoft.Owin.Host.SystemWeb.dll!Owin.Loader.DefaultLoader.MakeDelegate.AnonymousMethod__b(Owin.IAppBuilder builder)   Unknown
    Microsoft.Owin.Host.SystemWeb.dll!Owin.Loader.DefaultLoader.LoadImplementation.AnonymousMethod__0(Owin.IAppBuilder builder) Unknown
    Microsoft.Owin.Host.SystemWeb.dll!Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint.AnonymousMethod__0(Owin.IAppBuilder builder) Unknown
    Microsoft.Owin.Host.SystemWeb.dll!Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(System.Action<Owin.IAppBuilder> startup)  Unknown
    Microsoft.Owin.Host.SystemWeb.dll!Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(System.Action<Owin.IAppBuilder> startup)  Unknown
    Microsoft.Owin.Host.SystemWeb.dll!Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint()    Unknown
    mscorlib.dll!System.Threading.LazyInitializer.EnsureInitializedCore<System.__Canon>(ref System.__Canon target, ref bool initialized, ref object syncLock, System.Func<System.__Canon> valueFactory) Unknown
    Microsoft.Owin.Host.SystemWeb.dll!Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(System.Web.HttpApplication context) Unknown
    System.Web.dll!System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(System.IntPtr appContext, System.Web.HttpContext context, System.Reflection.MethodInfo[] handlers)  Unknown
    System.Web.dll!System.Web.HttpApplication.InitSpecial(System.Web.HttpApplicationState state, System.Reflection.MethodInfo[] handlers, System.IntPtr appContext, System.Web.HttpContext context) Unknown
    System.Web.dll!System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(System.IntPtr appContext, System.Web.HttpContext context)    Unknown
    System.Web.dll!System.Web.Hosting.PipelineRuntime.InitializeApplication(System.IntPtr appContext)   Unknown
    [AppDomain Transition]  

Repro steps:
Run a website in IISExpress. Save the web.config and reload the site several times.
About 4-5 tries later of recycling the site it hangs.

I tried debugging the disassembled code and all I could see is the code jumping indefinitely between those two functions.

>   System.dll!System.Diagnostics.PerformanceCounterLib.GetPerformanceCounterLib(string machineName, System.Globalization.CultureInfo culture)  Unknown
>   System.dll!System.Diagnostics.PerformanceCounterLib.IsCustomCategory(string machine, string category)   Unknown

This looks to me like a by-product of this bug:
http://connect.microsoft.com/VisualStudio/feedback/details/864245/multithreaded-bug-in-system-diagnostics-performancecounter

I'd like to have a config value to disable the creation of Performance Counters so I can avoid this problem if possible.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions