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
After a few seconds:
NullReferenceException in DiagnosticsEventListener.OnEventWritten.
The listener field is null.
Expected Behavior
No exception.
Version Info
SDK Version : 2.4.0 to 2.9.1
.NET Version : .NET Core 2.2 (although I think it repros on other platforms too)
How Application was onboarded with SDK: VisualStudio
OS : Windows 10
Hosting Info (IIS/Azure WebApps/ etc) : N/A
This issue has been plaguing my unit tests for Snapshot Debugger for that last week or so. It's timing dependent.
Explanation for the repro:
Race1 just creates and disposes an InMemoryChannel over and over. That has the effect of reporting "No Telemetry Items passed to Enqueue" to the CoreEventSource over and over.
Race2 creates and disposes the TelemetryConfiguration.Active. A lot happens there, but the important thing for the repro is that it adds the DiagnosticsTelemtryModule which establishes the DiagnosticsEventListener.
The two threads race with each other. At some point, the DiagnosticsEventListener constructor begins. It first calls the base class; note that the listener and logLevel fields are not yet set -- they're still null and zero. During the base class constructor, the OnEventSourceCreated virtual method is called. This is unusual; a quirk of EventListener. We detect that the event source is the CoreEventSource and enable it with AllKeyword and a logLevel of zero - LogAlways (that's a bug actually because it doesn't honor the logLevel that was passed in the constructor, but it's not this bug). Now that the event source is enabled, the other thread gets a chance to run -- to write an event. DiagnosticsEventListener's constructor still hasn't completed, but it gets a callback on OnEventWritten and gets all the way to the last line where listener is still null. NRE.
The text was updated successfully, but these errors were encountered:
pharring
added a commit
to pharring/ApplicationInsights-dotnet
that referenced
this issue
Mar 30, 2019
I believe, to fix the mis-configured 'logLevel', you would need to do something like that: Remember the set of EventSources that you want to enable in a List, and then run through that list at the end of the derived constructor.
This is the same as #341 (I can't re-open that one, though). Now I have a root cause and a fix ready to go.
Repro Steps
Compile and run this console app on .NET Core referencing the latest ApplicationInsights (base) NuGet (actually it repros as far back as 2.4.0):
Actual Behavior
After a few seconds:
NullReferenceException in DiagnosticsEventListener.OnEventWritten.
The
listener
field is null.Expected Behavior
No exception.
Version Info
SDK Version : 2.4.0 to 2.9.1
.NET Version : .NET Core 2.2 (although I think it repros on other platforms too)
How Application was onboarded with SDK: VisualStudio
OS : Windows 10
Hosting Info (IIS/Azure WebApps/ etc) : N/A
This issue has been plaguing my unit tests for Snapshot Debugger for that last week or so. It's timing dependent.
Explanation for the repro:
The two threads race with each other. At some point, the DiagnosticsEventListener constructor begins. It first calls the base class; note that the
listener
andlogLevel
fields are not yet set -- they're still null and zero. During the base class constructor, theOnEventSourceCreated
virtual method is called. This is unusual; a quirk of EventListener. We detect that the event source is the CoreEventSource and enable it withAllKeyword
and a logLevel of zero -LogAlways
(that's a bug actually because it doesn't honor the logLevel that was passed in the constructor, but it's not this bug). Now that the event source is enabled, the other thread gets a chance to run -- to write an event. DiagnosticsEventListener's constructor still hasn't completed, but it gets a callback onOnEventWritten
and gets all the way to the last line wherelistener
is still null. NRE.The text was updated successfully, but these errors were encountered: