Skip to content

Remove invalid live-target assert in cDAC DacEnumerableHash - #130629

Merged
max-charlamb merged 3 commits into
dotnet:mainfrom
max-charlamb:cdac-fix-dacenumerablehash-live-assert
Jul 13, 2026
Merged

max-charlamb merged 3 commits into
dotnet:mainfrom
max-charlamb:cdac-fix-dacenumerablehash-live-assert

Conversation

@max-charlamb

Copy link
Copy Markdown
Member

Summary

Removes an invalid Debug.Assert(Count == entries.Count) in the cDAC DacEnumerableHash reader. One of a cluster of cDAC GC stress-test robustness fixes split out of #130447.

The bug

Count and the bucket chains are only guaranteed consistent for a quiescent table -- the frozen-dump case the native DAC walker assumes. The cDAC stress harness reads this hash from a live process where the runtime may be concurrently inserting entries or growing the table (allocating a new bucket array chained via SLOT_NEXT and migrating entries), so the stored Count legitimately diverges from what a single-snapshot bucket walk observes.

This only affects Debug/Checked cDAC builds (the stress harness itself runs a Release cDAC). The assert is replaced with an explanatory comment.

Note

This PR description and the changes were produced with the assistance of GitHub Copilot.

Debug.Assert(Count == entries.Count) is only valid for a quiescent table
(the frozen-dump case the native DAC walker assumes). The cDAC stress
harness reads this hash from a LIVE process where the runtime may be
growing the table (new bucket array chained via SLOT_NEXT with entries
migrating), so the stored Count legitimately diverges from a
single-snapshot bucket walk. This only affects Debug/Checked cDAC builds.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 3508d1b8-e4de-4d3e-981f-79fe92c12f2c
@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.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 3508d1b8-e4de-4d3e-981f-79fe92c12f2c

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

This PR removes a Debug.Assert(Count == entries.Count) from the managed cDAC DacEnumerableHash reader and replaces it with a comment explaining why that invariant doesn’t hold when reading from a non-quiescent (live) target. This aligns the managed reader’s expectations with the underlying native DacEnumerableHashTable design, which supports concurrent growth and migration via SLOT_NEXT.

Changes:

  • Removed the System.Diagnostics dependency by deleting the Debug.Assert(Count == entries.Count) invariant check.
  • Added an explanatory comment documenting why Count can legitimately diverge from a single-pass bucket walk on live targets.

Copilot AI review requested due to automatic review settings July 13, 2026 14:43

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

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

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 3508d1b8-e4de-4d3e-981f-79fe92c12f2c
Copilot AI review requested due to automatic review settings July 13, 2026 14:57

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@max-charlamb
max-charlamb requested a review from rcj1 July 13, 2026 16:04
@max-charlamb
max-charlamb marked this pull request as ready for review July 13, 2026 16:04
@max-charlamb
max-charlamb merged commit db330a0 into dotnet:main Jul 13, 2026
77 checks passed
@max-charlamb
max-charlamb deleted the cdac-fix-dacenumerablehash-live-assert branch July 13, 2026 20:32
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 14, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
## Summary

Removes an invalid `Debug.Assert(Count == entries.Count)` in the cDAC
`DacEnumerableHash` reader. One of a cluster of cDAC GC stress-test
robustness fixes split out of #130447.

## The bug

`Count` and the bucket chains are only guaranteed consistent for a
**quiescent** table -- the frozen-dump case the native DAC walker
assumes. The cDAC stress harness reads this hash from a **live** process
where the runtime may be concurrently inserting entries or growing the
table (allocating a new bucket array chained via `SLOT_NEXT` and
migrating entries), so the stored `Count` legitimately diverges from
what a single-snapshot bucket walk observes.

This only affects Debug/Checked cDAC builds (the stress harness itself
runs a Release cDAC). The assert is replaced with an explanatory
comment.

> [!NOTE]
> This PR description and the changes were produced with the assistance
of GitHub Copilot.

---------

Co-authored-by: Max Charlamb <[email protected]>
Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 13, 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