Skip to content

Align NativeAOT generic marshalling rejection with CoreCLR - #133400

Merged
MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:fix/nativeaot-generic-marshalling-validation
Sep 9, 2026
Merged

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:fix/nativeaot-generic-marshalling-validation

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Resolves dotnet/runtimelab#177.

This was another wide disablement that got copypasted into tests that have nothing to do with COM. We should run them.

Reject generic interfaces and validate generic types before accepting blittable byref returns. Re-enable all 38 affected NativeAOT Generics tests.

Reject generic interfaces and validate generic types before accepting blittable byref returns. Re-enable all 38 affected NativeAOT Generics tests.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 3dea65e4-6bec-47a1-b938-b02f43d8a0bb
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 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: @agocke, @dotnet/ilc-contrib
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.

🔵 Needs a closer look

It changes core marshalling classification behavior in shared compiler tooling, so a human review should validate broader interop impact across platforms/configurations.

Pull request overview

Aligns NativeAOT’s generic marshalling rejection behavior with existing CoreCLR expectations by tightening marshalling classification rules, and re-enables previously-disabled interop generics tests that were broadly skipped for NativeAOT.

Changes:

  • Update marshalling kind selection to (1) validate generic types before allowing blittable byref returns and (2) reject generic interfaces from being marshaled.
  • Remove ActiveIssue(... IsNativeAot ...) skips from the Interop/PInvoke/Generics test suite so these tests execute under NativeAOT again.
File summaries
File Description
src/coreclr/tools/Common/TypeSystem/Interop/IL/MarshalHelpers.cs Tightens generic marshalling classification (generic interface rejection; validate generics for byref return).
src/tests/Interop/PInvoke/Generics/GenericsTest.VectorU.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.VectorL.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.VectorF.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.VectorD.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.VectorC.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.VectorB.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector64U.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector64L.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector64F.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector64D.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector64C.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector64B.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector256U.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector256L.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector256F.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector256D.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector256C.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector256B.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector128U.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector128L.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector128F.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector128D.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector128C.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.Vector128B.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.SpanU.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.SpanL.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.SpanF.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.SpanD.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.ReadOnlySpanU.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.ReadOnlySpanL.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.ReadOnlySpanF.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.ReadOnlySpanD.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.IComInterfaceU.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.IComInterfaceL.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.IComInterfaceF.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.IComInterfaceD.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.IComInterfaceC.cs Remove NativeAOT ActiveIssue skip.
src/tests/Interop/PInvoke/Generics/GenericsTest.IComInterfaceB.cs Remove NativeAOT ActiveIssue skip.
Review details
  • Files reviewed: 39/39 changed files
  • Comments generated: 1
  • Review effort level: Lite

@hez2010

hez2010 commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

I think we are still missing a case in the tests where generic function pointers in CoreCLR reject cases when runtime marshalling is involved (i.e. when being actually used, instead of being in the context only but unused), but NativeAOT happily accepts them.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

I think we are still missing a case in the tests where generic function pointers in CoreCLR reject cases when runtime marshalling is involved (i.e. when being actually used, instead of being in the context only but unused), but NativeAOT happily accepts them.

If/when we care enough to add a test we'll care enough on native AOT side too.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/ba-g mono crash was #133442

@MichalStrehovsky
MichalStrehovsky enabled auto-merge (squash) September 9, 2026 04:56
@MichalStrehovsky
MichalStrehovsky merged commit a2e0398 into dotnet:main Sep 9, 2026
122 of 125 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the fix/nativeaot-generic-marshalling-validation branch September 9, 2026 04:57
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 9, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Block generic COM interfaces

4 participants