This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Tighten GC mode assertion for EventPipe::Enable()#24124
Merged
Conversation
jkotas
approved these changes
Apr 19, 2019
Author
|
@dotnet-bot Test Windows_NT x64 Checked CoreFX Tests please |
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
Commit migrated from dotnet/coreclr@b269345
This file contains hidden or 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
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.
According to the documentation, QCALL involves a proper PInvoke transition frame, which means unless explicitly switched, the native code paths are in preemptive mode. That gives us an opportunity to tighten the asserts. Tightening the assert allows us to catch current bugs, prevent future regressions and better (live) document what the mode is supposed to be.
As far as I understand,
EventPipe::Enable()could happen only if it is triggered in managed code through QCALL or from IPC (which is purely native code), therefore we can assert native code that is used only forEventPipe::Enable()has to be in preemptive mode. This analysis forms the basis of this PR, so if this is incorrect, feel free to comment on this analysis.I proved (though tedious manual static code analysis) that the functions I changed are called only in the
EventPipe::Enable(). Feel free to comment if you found the code I changed could be called by other code-path, because if that's the case, my assumption might be wrong. It might not capture all calls that are involved only inEventPipe::Enable(), so feel free to point those out as well.For calls that are used in
EventPipe::Write()cannot be tightened because we knew it might be called directly (through the code generator) in random places in the runtime where it might already be in cooperative mode (I was able to prove in some caseEventPipe::Write()is indeed called by thread in cooperative mode. (Those calls should be scrutinized for their potential to block GC).