Skip to content

[cDAC] Add continuation support to RuntimeTypeSystem#124918

Open
max-charlamb wants to merge 3 commits intodotnet:mainfrom
max-charlamb:cdac-continuation-support
Open

[cDAC] Add continuation support to RuntimeTypeSystem#124918
max-charlamb wants to merge 3 commits intodotnet:mainfrom
max-charlamb:cdac-continuation-support

Conversation

@max-charlamb
Copy link
Member

@max-charlamb max-charlamb commented Feb 26, 2026

Summary

Add IsContinuation to the cDAC RuntimeTypeSystem contract, enabling the cDAC to identify and validate continuation MethodTables created by the async continuation feature.

Continuations are dynamically-created MethodTables (similar to arrays) whose parent is the base Continuation class stored in g_pContinuationClassIfSubTypeCreated. Without this change, the cDAC's MT→EEClass→MT validation roundtrip would reject valid continuation MTs.

Related discussion: #124780 (comment)

Changes

  • datadescriptor.inc — Expose g_pContinuationClassIfSubTypeCreated as ContinuationMethodTable global pointer
  • IRuntimeTypeSystem.cs — Add IsContinuation(TypeHandle) to the contract interface
  • RuntimeTypeSystem_1.cs — Implement IsContinuation by checking ParentMethodTable == continuationMethodTablePointer
  • RuntimeTypeSystemFactory.cs — Read the continuation MT global (gracefully handles missing global via TryReadGlobalPointer)
  • TypeValidation.cs — Fix MT→EEClass→MT validation to allow continuations (like arrays/generics)
  • Constants.cs — Add ContinuationMethodTable constant name
  • Tests — 4 test methods (8 cases across architectures): true positive, true negative, null global, and CanonMT validation

@dotnet-policy-service
Copy link
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 draft February 26, 2026 18:49
Copy link
Contributor

Copilot AI left a comment

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 adds continuation MethodTable identification to the cDAC RuntimeTypeSystem contract, enabling proper validation of dynamically-created continuation types used by the async continuation feature. Continuations are similar to arrays in that they are dynamically created and share EEClasses, requiring special handling in the MT→EEClass→MT validation roundtrip.

Changes:

  • Exposes the g_pContinuationClassIfSubTypeCreated global pointer to cDAC for continuation identification
  • Adds IsContinuation(TypeHandle) API to detect continuation types by checking parent MethodTable
  • Fixes TypeValidation to handle continuation MTs alongside arrays and generic instantiations

Reviewed changes

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

Show a summary per file
File Description
src/coreclr/vm/datadescriptor/datadescriptor.inc Exposes g_pContinuationClassIfSubTypeCreated as ContinuationMethodTable global pointer
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs Adds IsContinuation method to contract interface with documentation
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Constants.cs Adds ContinuationMethodTable constant name
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystemFactory.cs Reads continuation MT global using TryReadGlobalPointer (handles missing global gracefully)
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs Implements IsContinuation by comparing parent MT to continuation global pointer
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/TypeValidation.cs Adds continuation check to MT→EEClass→MT validation logic alongside arrays/generics
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.RuntimeTypeSystem.cs Adds test infrastructure for continuation MT global pointer
src/native/managed/cdac/tests/MethodTableTests.cs Adds 4 comprehensive test methods covering true positive, true negative, null global, and CanonMT validation scenarios

@max-charlamb max-charlamb force-pushed the cdac-continuation-support branch 2 times, most recently from a8e1857 to 492067a Compare February 26, 2026 19:07
Copilot AI review requested due to automatic review settings February 26, 2026 19:07
Copy link
Contributor

Copilot AI left a comment

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 9 out of 9 changed files in this pull request and generated no new comments.

@max-charlamb max-charlamb marked this pull request as ready for review February 26, 2026 19:42
Copilot AI review requested due to automatic review settings February 26, 2026 19:42
Copy link
Contributor

Copilot AI left a comment

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 9 out of 9 changed files in this pull request and generated no new comments.

Copy link
Contributor

Copilot AI left a comment

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 12 out of 12 changed files in this pull request and generated 1 comment.

@max-charlamb max-charlamb marked this pull request as ready for review February 27, 2026 18:25
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.

3 participants