Skip to content

[cDAC] Clear cached contract state on flush - #134615

Merged
max-charlamb merged 1 commit into
dotnet:mainfrom
max-charlamb:dev/max-charlamb/cdac-clear-cached-state
Sep 25, 2026
Merged

max-charlamb merged 1 commit into
dotnet:mainfrom
max-charlamb:dev/max-charlamb/cdac-clear-cached-state

Conversation

@max-charlamb

Copy link
Copy Markdown
Member

Summary

  • add a resettable CachedValue<T> for lazily initialized contract state
  • clear target-derived pointer caches from contract Flush implementations
  • propagate test-target flushes through resolved contracts and cover sync-table replacement

Contract instances survive Target.Flush, but several contracts retained pointers derived from mutable target globals in instance fields. Those pointers could remain stale after execution resumed or the target snapshot changed. This change keeps the existing per-contract caching efficiency while ensuring the values are re-read after a flush.

Testing

  • dotnet.cmd test src\native\managed\cdac\tests\UnitTests\Microsoft.Diagnostics.DataContractReader.Tests.csproj --no-restore -c Debug -p:RuntimeConfiguration=Debug -p:LibrariesConfiguration=Release (3,158 passed)

Note

This pull request description was generated with GitHub Copilot.

Use resettable cached values for target-derived pointers so contracts
re-read state after a target flush.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3f8294bb-306d-4f13-84c5-f8ecbe58ce02
@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.

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.

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds resettable lazy caches for cDAC contract state and invalidates them during target flushes.

Changes:

  • Introduces CachedValue<T>.
  • Updates affected contracts to clear target-derived caches.
  • Adds flush propagation and sync-table refresh coverage.
File Description
src/​native/​managed/​cdac/​tests/​UnitTests/​SyncBlockTests.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​tests/​UnitTests/​DebuggerTests.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​tests/​TestInfrastructure/​TestPlaceholderTarget.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​Microsoft.Diagnostics.DataContractReader.Contracts/​RuntimeTypeSystemHelpers/​TypeValidation.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​Microsoft.Diagnostics.DataContractReader.Contracts/​Contracts/​Thread_1.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​Microsoft.Diagnostics.DataContractReader.Contracts/​Contracts/​SyncBlock_1.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​Microsoft.Diagnostics.DataContractReader.Contracts/​Contracts/​RuntimeTypeSystem_1.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​Microsoft.Diagnostics.DataContractReader.Contracts/​Contracts/​Object_1.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​Microsoft.Diagnostics.DataContractReader.Contracts/​Contracts/​ExecutionManager/​ExecutionManagerCore.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​Microsoft.Diagnostics.DataContractReader.Contracts/​Contracts/​ComWrappers_1.cs Updated as part of this pull request.
src/​native/​managed/​cdac/​Microsoft.Diagnostics.DataContractReader.Contracts/​CachedValue.cs Updated as part of this pull request.

@max-charlamb

Copy link
Copy Markdown
Member Author

/ba-g known runtime-diagnostics pipeline issue

@max-charlamb
max-charlamb merged commit 1b2c09e into dotnet:main Sep 25, 2026
71 of 74 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 26, 2026
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.

4 participants