Skip to content

[cDAC] Encapsulate loader heap block traversal - #130729

Merged
max-charlamb merged 1 commit into
dotnet:mainfrom
max-charlamb:max-charlamb/cdac-enumerate-loader-heap-blocks
Jul 16, 2026
Merged

max-charlamb merged 1 commit into
dotnet:mainfrom
max-charlamb:max-charlamb/cdac-enumerate-loader-heap-blocks

Conversation

@max-charlamb

Copy link
Copy Markdown
Member

Summary

  • Replace raw loader heap block pointer APIs with EnumerateLoaderHeapBlocks returning only address and size.
  • Keep linked-list traversal and cycle detection inside the Loader contract.
  • Preserve SOS callback ordering, first-block marking, the 8192-block limit, S_FALSE behavior, and invalid-memory error mapping.
  • Update Loader documentation and contract/SOS unit tests.

This gives consumers the loader-heap data they need without exposing traversal pointers or requiring them to chase target-memory links.

Validation

  • dotnet build src\native\managed\cdac\cdac.slnx -c Debug -p:UseSharedCompilation=false /nr:false
  • dotnet test src\native\managed\cdac\tests\UnitTests\Microsoft.Diagnostics.DataContractReader.Tests.csproj -c Debug --no-build (2701 passed, 16 skipped)
  • Targeted LoaderHeapTests and LoaderTests run (224 passed)

Note

This PR was generated with the assistance of GitHub Copilot.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: f2aa5dc4-0c99-43f0-af14-734143849c4a
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
10 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.

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

Encapsulates loader heap block traversal inside the cDAC Loader contract by replacing the raw “linked-list pointer chasing” APIs with a single block enumeration API that exposes only block address + size. This reduces the amount of target-memory traversal logic (and related invariants like cycle detection) that each consumer needs to reimplement.

Changes:

  • Replaces GetFirstLoaderHeapBlock / GetLoaderHeapBlockData (LoaderHeapBlockData) with EnumerateLoaderHeapBlocks returning LoaderHeapBlock(Address, Size).
  • Updates the Loader_1 contract implementation to perform traversal + cycle detection internally.
  • Updates legacy SOS traversal and unit tests, and refreshes Loader contract documentation accordingly.

Reviewed changes

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

Show a summary per file
File Description
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ILoader.cs Replaces the loader-heap block API surface with EnumerateLoaderHeapBlocks + LoaderHeapBlock.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs Implements EnumerateLoaderHeapBlocks with internal traversal and cycle detection.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs Switches TraverseLoaderHeapCore to consume EnumerateLoaderHeapBlocks while preserving HRESULT mapping/limits.
src/native/managed/cdac/tests/UnitTests/LoaderTests.cs Updates VirtCallStubHeap traversal unit tests to mock the new enumeration API.
src/native/managed/cdac/tests/UnitTests/LoaderHeapTests.cs Updates loader heap traversal tests and adds a cyclic-heap coverage case for the new enumerator.
docs/design/datacontracts/Loader.md Updates the contract spec/signature and algorithm snippet to match the new enumeration API.

@max-charlamb
max-charlamb marked this pull request as ready for review July 15, 2026 00:59
@azure-pipelines

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

@max-charlamb
max-charlamb enabled auto-merge (squash) July 15, 2026 01:14
@max-charlamb
max-charlamb requested review from jkotas and rcj1 July 15, 2026 14:03
@max-charlamb

Copy link
Copy Markdown
Member Author

/ba-g tests pass, build analysis stuck

@max-charlamb
max-charlamb merged commit d92624e into dotnet:main Jul 16, 2026
90 checks passed
@max-charlamb
max-charlamb deleted the max-charlamb/cdac-enumerate-loader-heap-blocks branch July 16, 2026 14:46
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 16, 2026
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.

3 participants