Skip to content

[cDAC] ClrDataFrame.GetContext should use contextFlags to compute required context size #125791

Open

Description

@max-charlamb

Summary

ClrDataFrame.GetContext in the managed cDAC always returns the full platform context regardless of the contextFlags parameter. The native DAC implementation (stack.cpp) uses ContextSizeForFlags to compute the required context size based on the requested flags, and only copies/requires that subset.

Current Behavior

The cDAC implementation ignores contextFlags and always:

  • Reports contextSize as the full platform context length
  • Requires contextBufSize >= full context length (returns E_INVALIDARG otherwise)
  • Copies the entire context into the output buffer

Expected Behavior

Should match the native DAC:

  1. Use contextFlags to compute the required size via a ContextSizeForFlags equivalent
  2. Report the computed size via contextSize
  3. Only require contextBufSize >= computed size
  4. Copy only the relevant context fields

Affected Code

  • cDAC: src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataFrame.cs lines 38-92
  • Native reference: src/coreclr/debug/daccess/stack.cpp ClrDataFrame::GetContext

The TODO is at line 50:

// TODO: Use contextFlags to compute the required size via ContextSizeForFlags
// (see native ClrDataFrame::GetContext in stack.cpp). Currently we always
// return the full platform context regardless of the requested flags.

Impact

Currently callers that pass a smaller buffer sized for a subset of context flags will get E_INVALIDARG even though the native DAC would succeed. This doesn't affect SOS's !clrstack (which always requests the full context), but could affect other diagnostic tools.

/cc @max-charlamb

Activity

  1. added
    untriaged
    on Mar 19, 2026
  2. dotnet-policy-service commented on Mar 19, 2026

    @dotnet-policy-service
    Contributor

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

  3. removed
    untriaged
    on Mar 19, 2026
  4. added this to the 11.0.0 milestone on Jul 23, 2026
  5. modified the milestones: 11.0.0, 12.0.0 on Aug 5, 2026
  6. rcj1 commented on Aug 5, 2026

    @rcj1
    Contributor

    Moving this to 12 because nothing that I can see uses it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions