Open kataklinger opened 10 months ago
Tagging subscribers to this area: @mangod9 See info in area-owners.md if you want to be subscribed.
Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti See info in area-owners.md if you want to be subscribed.
Author: | kataklinger |
---|---|
Assignees: | - |
Labels: | `area-System.Diagnostics.Tracing`, `area-System.Threading`, `untriaged` |
Milestone: | - |
@kataklinger thanks for the excellent analysis! Please feel free to submit a PR if you are interested.
Hi @kataklinger, recently there have been several PRs merged that addressed similar deadlocks in EventSource/EventListener, so this may have been fixed. Do you have a simple repro for the scenario where you're running into the deadlock, or would you be able to try out .NET 9.0 (https://dotnet.microsoft.com/en-us/download/dotnet) to see if the problem persists?
This issue has been marked needs-author-action
and may be missing some important information.
Description
We have number of tests that are creating and disposing
System.Diagnostics.Tracing.EventListener
s. Since upgrading to .NET Core 8 if the tests are executed concurrently, usingdotnet test
, test runners started hanging for some of our tests. Attaching a debugger reveals a deadlock occurs in the code that is disposingEventListener
.Here's the stack traces of the two threads involved in the deadlock.
Thread1:
Thread 2:
The summary of stack traces from VS' Parallel Stacks tool shows that
EventListener.EventListenersLock
andEventPipeEventDispatcher.m_dispatchControlLock
locks are taken in the conflicting orders by the different code paths:Taking
EventListener.EventListenersLock
lock inEventListener.Dispose
seems to be against advice given by this comment:I could find following issues and PRs relevant to the problem:
Reproduction Steps
Not available at this time.
Expected behavior
One should be able to concurrently and repeatedly dispose
EventListener
s.Actual behavior
Deadlock occurs.
Regression?
No response
Known Workarounds
No response
Configuration
.NET Core 8 Windows 10 x64
Other information
No response