-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix deadlock in EventPipeEventDispatcher #90053
Conversation
Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti Issue DetailsFixes #86838 In EventPipeEventDispatcher we currently wait on the session to close synchronously before updating the configuration, this can lead to a deadlock if the dispatcher thread tries to call back in to EventSource apis (as described in #86838). This change fixes the deadlock by making stopping the session asynchronous, and moving the call to update EventPipeEventDispatcher outside of the EventListenersLock in EventListener.Dispose. This is the test program I used to recreate the deadlock. It would reliably hit the deadlock within a minute before, and can run for hours without a deadlock after
As part of this fix we discovered a latent bug in EventPipeEventDispatcher as described in #90052. We are too close to releasing .net 8 to make this kind of change so the work will happen in a later release.
|
62a94d8
to
9c2e4ee
Compare
There is a race condition still present - since both the old task and new task use the same |
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
Outdated
Show resolved
Hide resolved
There is a latent issue where ep_shutdown races with the EventPipeEventDispatcher thread, filed #90472 to track. |
The changes in this PR made the shutdown race much more prevalent, I added changes to address it. This PR now fixes #90472 as well. |
Test failures are all unrelated, merging. |
Fixes #86838
In EventPipeEventDispatcher we currently wait on the session to close synchronously before updating the configuration, this can lead to a deadlock if the dispatcher thread tries to call back in to EventSource apis (as described in #86838).
This change fixes the deadlock by making stopping the session asynchronous, and moving the call to update EventPipeEventDispatcher outside of the EventListenersLock in EventListener.Dispose.
This is the test program I used to recreate the deadlock. It would reliably hit the deadlock within a minute before, and can run for hours without a deadlock after
As part of this fix we discovered a latent bug in EventPipeEventDispatcher as described in #90052. We are too close to releasing .net 8 to make this kind of change so the work will happen in a later release.