-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[EventPipe] Block EventPipeProvider Deletion for ongoing callbacks #106040
Merged
mdh1418
merged 7 commits into
dotnet:main
from
mdh1418:eventpipe_block_unregister_for_callbacks_counter_signal_impl
Aug 7, 2024
Merged
[EventPipe] Block EventPipeProvider Deletion for ongoing callbacks #106040
mdh1418
merged 7 commits into
dotnet:main
from
mdh1418:eventpipe_block_unregister_for_callbacks_counter_signal_impl
Aug 7, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can you re-enable the disabled test? |
The change LGTM, but I am not deeply familiar with EventPipe code. |
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
davmason
reviewed
Aug 6, 2024
This was referenced Aug 6, 2024
Closed
lateralusX
reviewed
Aug 7, 2024
noahfalk
approved these changes
Aug 7, 2024
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.
Few comments inline but mostly looks good!
lateralusX
approved these changes
Aug 7, 2024
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
Give the callback data access to the associated provider so it can decrement the provider's callbacks counter after the callback invocation is completed.
Rename counter Add more comments describing the blocking behavior Add comments for potential deadlock scenario
mdh1418
force-pushed
the
eventpipe_block_unregister_for_callbacks_counter_signal_impl
branch
from
August 7, 2024 17:32
7878c1d
to
d28ed8e
Compare
/azp run runtime-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Aug 7, 2024
3 tasks
mdh1418
deleted the
eventpipe_block_unregister_for_callbacks_counter_signal_impl
branch
August 7, 2024 21:15
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #80666
This PR aims to align behavior between EventPipe's Unregister logic and ETW's Unregister logic by blocking EventPipe's DeleteProvider for in-flight callbacks, so that the gchandle will not be freed before the callback completes. (ETW has its own lock for ETW commands/callbacks).
Our initial attempt to add a corresponding EventPipe lock revealed to us that locks should not be taken around the callback (specifically performing the callback within a lock) because it breaks concurrent callbacks scenarios.
In this PR, we track the EventPipeProvider's callbacks that have been prepared but not yet invoked (i.e. in-flight callbacks), and leverage a signal set/wait to block the EventPipe Provider's deferred deletion.
Repro
Reproduced the crash by:
dotnet-trace collect --providers TestEventSource -p <pid of app from dotnet-trace ps>
Resulted in a NullReferenceException crash.
Testing
Performed the same steps as above with the changes in this PR, Dispose is blocked until the callback completes.