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 }}
Repository navigation
Race condition during TraceSource Initialization/Refresh #104457
TraceSource is documented to be a thread-safe, however when you call System.Diagnostics.Trace.Refresh() during TraceSource initialization from a different thread, you have a high chance of receiving either InvalidOperationException or NullReferenceException from the OnInitializing method during the enumeration of Listeners.
There seem to be a lack of synchronization on the collection, this seem to have been introduced in #73087
I can call System.Diagnostics.Trace.Refresh() safely from a different thread during underlying TraceSource initialization without the risk of crashing.
Actual behavior
A high chance of receiving either InvalidOperationException or NullReferenceException from the OnInitializing method during the enumeration of Listeners as the collection might have been modified or initialized from a different thread.
Regression?
Since #73087, previous .NET version (6) didn't suffer from this issue.
Known Workarounds
In case of WPF, wait some time before invoking a Refresh.
Configuration
.NET 8.0.6 x64 Win10
Reacted by Cole Tobin
Activity
ghost added
needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
Activity
dotnet-policy-service commentedon Jul 5, 2024
Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti
See info in area-owners.md if you want to be subscribed.
tommcdon commentedon Jul 6, 2024
@noahfalk @hoyosjs
ericstj commentedon Jul 17, 2024
@steveharter can you have a look at this?