We have a .NET Core 2.1 application in production on Azure. It has been, infrequently, coming down with an unrecoverable 500 error which necessitates a site restart. We have noticed the following exception/stack trace appearing in our Azure application insights log hundreds of times at these times.

We cannot easily reproduce the issue unfortunately; it happens unpredictably but with increasingly likelihood as time goes by.

Exception:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Microsoft.AspNetCore.Routing.RouteValueDictionary.ListStorage.Clear()
   at Microsoft.AspNetCore.Routing.RouteValueDictionary.Clear()
   at Microsoft.AspNetCore.Routing.RouteData.RouteDataSnapshot.Restore()
   at Microsoft.AspNetCore.Routing.RouteCollection.<RouteAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.<Invoke>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.<ProcessRequestsAsync>d__2.MoveNext()

Potentially relevant code; our route configuration:

app.UseMvc(routes =>
{
    var section = Configuration.GetSection("AppSettings:HostNames");
    var hostnames = section.Get<string[]>();

    // Prepare special routes
    routes.MapRoute("takeSurveyApi", "TakeSurvey/{action}/{id?}", new { controller = "TakeSurvey", action = "Index" });
    routes.MapRoute("takeSurvey", "TakeSurvey/{id?}", new { controller = "TakeSurvey", action = "Index" });
    routes.MapRoute("stripeWebhook", "Billing/WebHook", new { controller = "Billing", action = "WebHook" });

    routes.MapSubdomainRoute(
        hostnames,
        "MHP",
        "{tenant}",
        "MHP/{action}",
        new { controller = "MHP", action = "GetTenantDetails" });

    routes.MapSubdomainRoute(
        hostnames,
        "Localisation",
        "{tenant}",
        "Localisation/{action}",
        new { controller = "Localisation", action = "Get" });

    routes.MapSubdomainRoute(
        hostnames,
        "TenantInSubdomain",
        "{tenant}",
        "{*url}",
        new { controller = "Home", action = "Index" });

    routes.MapRoute(
        hostnames,
        "DefaultRoute",
        "{controller}/{action}/{id?}",
        new { controller = "Home", action = "Index" });               

    routes.MapRoute(
        hostnames, "reactRouter", "{*url}", new {controller = "Home", action = "Index"});
});

Additional context

dotnet --info` = 
.NET Core SDK (reflecting any global.json):
 Version:   2.1.500
 Commit:    b68b931422

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:Program Filesdotnetsdk2.1.500

Host (useful for support):
  Version: 2.1.6
  Commit:  3f4f8eebd8

.NET Core SDKs installed:
  1.0.0-preview2-003131 [C:Program Filesdotnetsdk]
  1.1.0 [C:Program Filesdotnetsdk]
  2.1.101 [C:Program Filesdotnetsdk]
  2.1.104 [C:Program Filesdotnetsdk]
  2.1.202 [C:Program Filesdotnetsdk]
  2.1.403 [C:Program Filesdotnetsdk]
  2.1.500 [C:Program Filesdotnetsdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.1 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here