Skip to content

Fix MarshalAs IID parameter index parsing#128364

Merged
MichalStrehovsky merged 8 commits into
mainfrom
copilot/fix-assertion-failure-in-marshalling
May 20, 2026
Merged

Fix MarshalAs IID parameter index parsing#128364
MichalStrehovsky merged 8 commits into
mainfrom
copilot/fix-assertion-failure-in-marshalling

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Fixes native AOT outerloop runs that are currently broken.

NativeAOT could assert while parsing valid MarshalAs metadata emitted for COM interface parameters using IidParameterIndex, leaving unread bytes in the marshal descriptor blob.

  • Parser

    • Consume optional IidParameterIndex payloads for COM interface native types:
      • IUnknown
      • IDispatch
      • Interface
    • Keep existing behavior of using only the native type in NativeAOT.
  • Regression coverage

    • Added TypeSystem coverage for descriptors like:
[MarshalAs(UnmanagedType.Interface, IidParameterIndex = 0)] out object value
  • Covered Interface, IUnknown, and IDispatch marshal descriptors.

Copilot AI and others added 7 commits May 19, 2026 11:44
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/6431b9d0-721f-4422-8e4f-28133f8e4e6a

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/6431b9d0-721f-4422-8e4f-28133f8e4e6a

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/6431b9d0-721f-4422-8e4f-28133f8e4e6a

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/6431b9d0-721f-4422-8e4f-28133f8e4e6a

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/6431b9d0-721f-4422-8e4f-28133f8e4e6a

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/6431b9d0-721f-4422-8e4f-28133f8e4e6a

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/6431b9d0-721f-4422-8e4f-28133f8e4e6a

Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Copilot AI self-assigned this May 19, 2026
Copilot AI review requested due to automatic review settings May 19, 2026 12:29
Copilot AI review requested due to automatic review settings May 19, 2026 12:29
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

@MichalStrehovsky MichalStrehovsky marked this pull request as ready for review May 19, 2026 12:39
@MichalStrehovsky MichalStrehovsky self-requested a review as a code owner May 19, 2026 12:39
Copilot AI review requested due to automatic review settings May 19, 2026 12:39
@MichalStrehovsky
Copy link
Copy Markdown
Member

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
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 updates the TypeSystem marshal descriptor parser to tolerate (and consume) the optional IidParameterIndex payload that can appear for COM-interface native types, and adds TypeSystem regression coverage to ensure these marshal blobs no longer trigger debug assertions due to unread bytes.

Changes:

  • Update EcmaSignatureParser.ParseMarshalAsDescriptor() to consume an optional compressed integer payload for IUnknown, IDispatch, and Interface native types.
  • Add TypeSystem tests that compile methods using [MarshalAs(..., IidParameterIndex = 0)] and validate the descriptor parses successfully.
  • Extend the CoreTestAssembly MarshalAsAttribute stub and add new methods that emit the relevant marshal descriptors.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs Consumes optional IidParameterIndex data for COM interface marshal descriptors to avoid leftover bytes/asserts.
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/MarshalUtilsTests.cs Adds regression test validating the marshal descriptor type parses for COM interface cases with IidParameterIndex.
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CoreTestAssembly/Platform.cs Updates the CoreTestAssembly MarshalAsAttribute stub to allow IidParameterIndex named argument in test code.
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CoreTestAssembly/Marshalling.cs Adds test methods that use MarshalAs(..., IidParameterIndex = 0) for IUnknown/IDispatch/Interface.

Comment thread src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs Outdated
Copilot AI review requested due to automatic review settings May 19, 2026 12:59
@MichalStrehovsky
Copy link
Copy Markdown
Member

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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

@MichalStrehovsky
Copy link
Copy Markdown
Member

@dotnet/ilc-contrib could someone have a look? #128214 broke outerloop builds and we can't test

@MichalStrehovsky
Copy link
Copy Markdown
Member

/ba-g helix issue

@MichalStrehovsky MichalStrehovsky merged commit 97d83e7 into main May 20, 2026
130 of 137 checks passed
@MichalStrehovsky MichalStrehovsky deleted the copilot/fix-assertion-failure-in-marshalling branch May 20, 2026 13:06
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