Avoid populating shared patch bypass buffer after initial creation#117514
Merged
tommcdon merged 9 commits intodotnet:mainfrom Jul 16, 2025
Merged
Avoid populating shared patch bypass buffer after initial creation#117514tommcdon merged 9 commits intodotnet:mainfrom
tommcdon merged 9 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors how the shared patch bypass buffer is created and accessed to eliminate a race condition by making the buffer read-only once it exists.
- Split
GetOrCreateSharedPatchBypassBufferinto separateCreateSharedPatchBypassBufferandGetSharedPatchBypassBuffermethods - Updated
DebuggerPatchSkipto only write to the buffer on initial creation and skip writes thereafter - Renamed calls and added guards around RW versus RX buffer access
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/debug/ee/controller.h | Renamed buffer accessor, splitting creation and retrieval into two distinct methods |
| src/coreclr/debug/ee/controller.cpp | Changed patch-skip logic to only populate the buffer when first created and guard subsequent writes |
Comments suppressed due to low confidence (2)
src/coreclr/debug/ee/controller.h:554
- [nitpick] The comment is now misleading for
CreateSharedPatchBypassBuffer. Consider updating it to describe that this method always creates a new buffer rather than just retrieving one.
// gets a pointer to the shared buffer
src/coreclr/debug/ee/controller.cpp:4534
- The variable name
SharedPatchBypassBufferWriterHolderhere refers to the class, not the instance. It should besharedPatchBypassBufferWriterHolder.AssignExecutableWriterHolder(...)to match the declared variable.
SharedPatchBypassBufferWriterHolder.AssignExecutableWriterHolder((SharedPatchBypassBuffer*)m_pSharedPatchBypassBuffer, sizeof(SharedPatchBypassBuffer));
Contributor
|
Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag |
This was referenced Jul 10, 2025
noahfalk
reviewed
Jul 11, 2025
noahfalk
approved these changes
Jul 14, 2025
Member
noahfalk
left a comment
There was a problem hiding this comment.
A few more style/refactoring suggestions inline. LGTM!
Co-authored-by: Noah Falk <[email protected]>
Encapsulate instruction attribute into SharedBypasBuffer
Open
3 tasks
Member
Author
|
Android timeout is unrelated, merging |
Member
Author
|
/ba-g failures are unrelated |
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.
Fixes #102767
This pull request changes DebuggerPatchSkip creation. Before this change we always populated the shared patch bypass buffer, which is used for patch skipping. Although the population of the patch skip buffer is done under the DebuggerController lock, as it is a shared buffer, it's possible we write to it while other threads are executing in the patch buffer which runs without the DebuggerController lock. This exposes a small race condition that can be hit with multiple threads executing on the same breakpoint location. This fix addresses the issue by effectively making the buffer read-only after it is created. There was a previous comment in the code stating that we always overwrite the buffer due to ReJIT jump stamps. Jump stamps were removed in the .NET Core 2.2 timeframe, and so it is believed that it should be safe to avoid constantly re-writing the patch buffer for each DebuggerPatchSkip creation