Skip to content

Fix memory ordering issue in GCHeap::StressHeap - #40983

Merged
PeterSolMS merged 1 commit into
dotnet:masterfrom
PeterSolMS:Fix_StressHeap_for_arm64
Aug 21, 2020
Merged

PeterSolMS merged 1 commit into
dotnet:masterfrom
PeterSolMS:Fix_StressHeap_for_arm64

Conversation

@PeterSolMS

Copy link
Copy Markdown
Contributor

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

…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.
@ghost

ghost commented Aug 18, 2020

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/gc
See info in area-owners.md if you want to be subscribed.

@trylek

trylek commented Aug 18, 2020

Copy link
Copy Markdown
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.

@Maoni0

Maoni0 commented Aug 18, 2020

Copy link
Copy Markdown
Member

ahh yes this for sure should be fixed. thanks!

@echesakov

Copy link
Copy Markdown
Contributor

@PeterSolMS
PeterSolMS merged commit e336921 into dotnet:master Aug 21, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants