-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Mirror of dotnet/runtime#77434
EventSource.IsEnabled()
may start returning true
before the OnEventCommand
completes.
We initialize shared EventCounter
instances in OnEventCommand
that we then use from instrumented code paths.
If the EventSource
is initialized before being enabled, and the instance is accessed from multiple threads, a thread could see IsEnabled() == true
and then read a null
EventCounter
instance.
This race condition only appears once per process.
I believe this is the cause of an exception YARP hit in CI:
System.NullReferenceException : Object reference not set to an instance of an object.
at System.Net.Http.HttpTelemetry.Http11RequestLeftQueue(Double timeOnQueueMilliseconds)
at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
We should fix these cases.
cc: @Tratcher aspnetcore has 2 such cases as well:
aspnetcore/src/Middleware/ConcurrencyLimiter/src/ConcurrencyLimiterEventSource.cs
Line 47 in 1e8fe7e
_queueDuration!.WriteMetric(0); |
aspnetcore/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsEventSource.cs
Line 46 in 1e8fe7e
_connectionDuration!.WriteMetric(duration); |