You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
#115
Open
Gh0stWalk3r opened this issue
Apr 27, 2021
· 3 comments
Hi @AlexTeixeira,
first I want to thank you for this great library and I hope you are doing well.
Today I had a lot of invalid operation exceptions with the following message and stack trace:
Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
at System.Collections.Generic.HashSet`1.Contains(T item)
at Askmethat.Aspnet.JsonLocalizer.Localizer.JsonStringLocalizerBase.AddMissingCultureToSupportedCulture(CultureInfo cultureInfo)
at Askmethat.Aspnet.JsonLocalizer.Localizer.JsonStringLocalizerBase.InitJsonStringLocalizer()
at ResolveService(ILEmitResolverBuilderRuntimeContext , ServiceProviderEngineScope )
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at lambda_method(Closure , IServiceProvider , Object[] )
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Extensions.Web.Api.Middleware.ApiLoggingMiddleware.InvokeAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()
The application is an ASP.NET CORE 3.1 app with the library version 2.2.0-preview3. Although the library seems to be outdated, the part of the code where the issue arises is identical.
I think the issue occurs due to a change of dotnet/runtime#26868, where Hashsets are never thread safe for a write and any other operation (read or write) since release of .NET CORE 2.1.0.
From this I assume the IOptions<JsonLocalizationOptions> _localizationOptions is beeing modified concurrently in Localizer/JsonStringLocalizerBase.cs#L100-L106 and therefore the InvalidOperationException is thrown.
Kind regards, Greg
The text was updated successfully, but these errors were encountered:
Hi @AlexTeixeira,
Thanks a lot for your support and great work.
Unfortunately I can not verify the changes as I have moved to a different company.
Please, feel free to close this issue.
I hope you are doing well and wish you all the best 🙂
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi @AlexTeixeira,
first I want to thank you for this great library and I hope you are doing well.
Today I had a lot of invalid operation exceptions with the following message and stack trace:
Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
The application is an ASP.NET CORE 3.1 app with the library version 2.2.0-preview3. Although the library seems to be outdated, the part of the code where the issue arises is identical.
I think the issue occurs due to a change of dotnet/runtime#26868, where Hashsets are never thread safe for a write and any other operation (read or write) since release of .NET CORE 2.1.0.
From this I assume the
IOptions<JsonLocalizationOptions> _localizationOptions
is beeing modified concurrently in Localizer/JsonStringLocalizerBase.cs#L100-L106 and therefore the InvalidOperationException is thrown.Kind regards, Greg
The text was updated successfully, but these errors were encountered: