Skip to content

Fix cDAC server GC free region enumeration - #132704

Open
max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:dev/max-charlamb/fix-server-gc-free-regions
Open

Fix cDAC server GC free region enumeration#132704
max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:dev/max-charlamb/fix-server-gc-free-regions

Conversation

@max-charlamb

Copy link
Copy Markdown
Member

Server GC stores free_regions as an inline array within each GC heap. The cDAC model currently treats this field as a pointer, causing the first list's num_free_regions value to be interpreted as an address. This can produce invalid reads such as 0x2b when enumerating server GC free regions.

This changes GCHeapSVR.FreeRegions to use FieldAddress and adds unit coverage for the server GC inline free-region array across all target architectures.

Tests:

  • Microsoft.Diagnostics.DataContractReader.Tests: 3,098 passed

Note

This pull request description was generated with GitHub Copilot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d56e1d60-7e1a-4353-8d3f-27deac700b4f
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@max-charlamb
max-charlamb marked this pull request as ready for review August 24, 2026 15:39
@max-charlamb
max-charlamb requested review from noahfalk and rcj1 and a lite review from Copilot August 24, 2026 15:39
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes server GC free-region enumeration in cDAC by treating GCHeapSVR.FreeRegions as an inline array (address-of field) rather than a pointer value, preventing invalid reads during enumeration.

Changes:

  • Switch GCHeapSVR.FreeRegions from [Field] to [FieldAddress] so the contract uses the field’s address.
  • Add a unit test covering server heap inline FreeRegions enumeration across standard architectures.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/native/managed/cdac/tests/UnitTests/GCMemoryRegionTests.cs Adds coverage for enumerating server GC inline free-region arrays via mocked heap layout.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/GC/GCHeapSVR.cs Updates FreeRegions to use [FieldAddress] so enumeration uses the inline array base address.

Comment thread src/native/managed/cdac/tests/UnitTests/GCMemoryRegionTests.cs
@max-charlamb
max-charlamb requested a review from steveisok August 24, 2026 19:16
@max-charlamb
max-charlamb enabled auto-merge (squash) August 24, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants