Skip to content

[WIP] Implement IXCLRDataExceptionState state comparison#131011

Draft
rcj1 wants to merge 4 commits into
mainfrom
copilot/exception-dac
Draft

[WIP] Implement IXCLRDataExceptionState state comparison#131011
rcj1 wants to merge 4 commits into
mainfrom
copilot/exception-dac

Conversation

@rcj1

@rcj1 rcj1 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 18, 2026 04:05
@rcj1
rcj1 temporarily deployed to copilot-pat-pool July 18, 2026 04:05 — with GitHub Actions Inactive
@rcj1
rcj1 temporarily deployed to copilot-pat-pool July 18, 2026 04:05 — with GitHub Actions Inactive
@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.

@rcj1
rcj1 had a problem deploying to copilot-pat-pool July 18, 2026 04:06 — with GitHub Actions Failure
@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.

@rcj1
rcj1 temporarily deployed to copilot-pat-pool July 18, 2026 04:07 — with GitHub Actions Inactive
@rcj1
rcj1 temporarily deployed to copilot-pat-pool July 18, 2026 04:08 — with GitHub Actions Inactive
@rcj1
rcj1 temporarily deployed to copilot-pat-pool July 18, 2026 04:08 — with GitHub Actions Inactive

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

Implements IXCLRDataExceptionState.IsSameState / IsSameState2 in the cDAC legacy shim and adds unit tests to validate the HRESULT behavior when comparing exception state based on exception address and “first-chance” semantics.

Changes:

  • Implement IXCLRDataExceptionState.IsSameState and IsSameState2 in ClrDataExceptionState (including DEBUG-only validation against the legacy DAC implementation).
  • Add unit tests for state comparison (IsSameState / IsSameState2) and flag validation behavior.
Show a summary per file
File Description
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ClrDataExceptionState.cs Adds cDAC implementation of exception state comparison logic for IsSameState/IsSameState2.
src/native/managed/cdac/tests/UnitTests/ClrDataExceptionStateTests.cs Adds unit tests covering matching/different exception addresses and IsSameState2 flag handling.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment on lines +261 to +263
ThreadData threadData = _target.Contracts.Thread.GetThreadData(_threadAddress);
TargetPointer exceptionAddress = _target.ReadPointer(
threadData.OSExceptionRecord + (ulong)(sizeof(uint) * 2 + _target.PointerSize));
Comment on lines +360 to +371
[Theory]
[ClassData(typeof(MockTarget.StdArch))]
public void IsSameState2_DifferentAddress(MockTarget.Architecture arch)
{
const ulong exceptionAddress = 0x1234_5678;
IXCLRDataExceptionState exceptionState = CreateExceptionStateWithRecord(arch, exceptionAddress);
EXCEPTION_RECORD64 inputRecord = new() { ExceptionAddress = exceptionAddress + 1 };

int hr = exceptionState.IsSameState2(0, &inputRecord, 0, null);

Assert.Equal(HResults.S_FALSE, hr);
}
@rcj1 rcj1 changed the title Implement IXCLRDataExceptionState state comparison [WIP] Implement IXCLRDataExceptionState state comparison Jul 18, 2026
@rcj1

rcj1 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot 1. please put both flags under CLRDATA_EXCEPTION_PARTIAL in an enum in IXCLRData.cs.
2. resolve #131011 (comment) by modifying the CLRDataExceptionState managed constructor to take the previous exception info as a parameter.

Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 18, 2026 05:13
Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>

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's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

Copilot AI review requested due to automatic review settings July 18, 2026 05:17

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@copilot 1. please put both flags under CLRDATA_EXCEPTION_PARTIAL in an enum in IXCLRData.cs.
2. resolve #131011 (comment) by modifying ...

Implemented in a554b966 with naming clarification in 48f1797d. The comparison flags now use CLRDataExceptionSameFlag, nested states retain their exception-info address through GetPrevious, and invalid flags throw ArgumentException within the HRESULT boundary.

Copilot finished work on behalf of rcj1 July 18, 2026 05:20

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's findings

Comments suppressed due to low confidence (1)

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/IXCLRData.cs:969

  • This adds a new public enum type to the Legacy assembly. Unless this is intended to be part of the supported public surface, consider making it internal (tests can still access it via InternalsVisibleTo) to avoid expanding public API and triggering API-approval requirements.
[Flags]
public enum CLRDataExceptionSameFlag : uint
{
    CLRDATA_EXSAME_SECOND_CHANCE = 0,
    CLRDATA_EXSAME_FIRST_CHANCE = 0x1,
}
  • Files reviewed: 5/5 changed files
  • Comments generated: 1

Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 18, 2026 05:39

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's findings

Comments suppressed due to low confidence (1)

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/IXCLRData.cs:969

  • This change introduces new public API surface (CLRDataExceptionSameFlag). The provided PR metadata doesn’t include any linked api-approved issue/proposal, which is required for new public APIs in dotnet/runtime. Either (1) link the approved API proposal/issue, or (2) make this enum internal if it’s only intended for internal/test use (the Legacy csproj already has InternalsVisibleTo for the tests).
[Flags]
public enum CLRDataExceptionSameFlag : uint
{
    CLRDATA_EXSAME_SECOND_CHANCE = 0,
    CLRDATA_EXSAME_FIRST_CHANCE = 0x1,
}
  • Files reviewed: 5/5 changed files
  • Comments generated: 1

Comment on lines +399 to +406
const ulong exceptionAddress = 0x1234_5678;
IXCLRDataExceptionState exceptionState = CreateExceptionStateWithRecord(arch, exceptionAddress);
EXCEPTION_RECORD64 inputRecord = new() { ExceptionAddress = exceptionAddress + 1 };

int hr = exceptionState.IsSameState2((uint)CLRDataExceptionSameFlag.CLRDATA_EXSAME_SECOND_CHANCE, &inputRecord, 0, null);

Assert.Equal(HResults.S_FALSE, hr);
}
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