Repository navigation
Fix memory ordering issue in GCHeap::StressHeap - #40983
Merged
Merged
Conversation
…ite to the new free object is seen *before* the write to the string length, otherwise the heap won't be walkable, leading to an AV in background_sweep.
|
Tagging subscribers to this area: @dotnet/gc |
Member
|
Thanks Peter! I have launched a private Crossgen2 GC stress run - we see many of these GC stress runtime failures in those runs so it should be very easy to see what difference your change has made. |
Member
|
ahh yes this for sure should be fixed. thanks! |
Maoni0
approved these changes
Aug 18, 2020
Contributor
|
gcstress-extra test runs for the change - https://dev.azure.com/dnceng/public/_build/results?buildId=777199&view=results |
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.
StressHeap contains a hack where we chop off the end of a string allocated for that purpose and make a new free object out of the chopped of piece. We also reduce the size of the string, so the GC sees the free object when walking the heap - the idea is to force compaction.
On processors with weak memory ordering semantics, we need a memory barrier to make sure the write to the new free object is seen before the write to the string length, otherwise the heap won't be walkable, leading to an AV in background_sweep.
I don't know at this point whether this will fix the arm64 GC stress issues we have been seeing, but the one dump I have been able to capture shows background_sweep crashing on a free object of size 0x2e8, which is exactly what StressHeap carves off the end of the string, plus there is a string will all null characters right before in memory, so we have some evidence that the free object whose method table was read as null by the GC was written by GCHeap::StressHeap.
cc @AndyAyersMS @trylek