Skip to content

Check for ComInterop case for async variants in crossgen2#129747

Merged
jakobbotsch merged 4 commits into
dotnet:mainfrom
jakobbotsch:fix-129739
Jun 25, 2026
Merged

Check for ComInterop case for async variants in crossgen2#129747
jakobbotsch merged 4 commits into
dotnet:mainfrom
jakobbotsch:fix-129739

Conversation

@jakobbotsch

@jakobbotsch jakobbotsch commented Jun 23, 2026

Copy link
Copy Markdown
Member

This check was added in the VM, but a similar check must be added in crossgen2 to avoid generating calls to async variants of ComImport methods in crossgen2.

Fix #129739

Copilot AI review requested due to automatic review settings June 23, 2026 13:24
@github-actions github-actions Bot added the area-crossgen2-coreclr only use for closed issues label Jun 23, 2026

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

Updates crossgen2’s JIT interface token/method handling to avoid resolving async variants in cases where no callable runtime async entrypoint will be generated (notably for COM-imported methods), addressing an async-variant resolution crash/assert scenario.

Changes:

  • Introduces a shared eligibility check (HasCallableAsyncVariant) for deciding whether an async variant can be used.
  • Uses the shared check when selecting the “other variant” in getAsyncOtherVariant.
  • Uses the shared check when resolving CORINFO_TOKENKIND_Await tokens to an async-variant method (or returning null to force fallback resolution).

Comment thread src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs Outdated
@jakobbotsch

Copy link
Copy Markdown
Member Author

I suppose it means that adding ComInterop to an existing interface that already was compiled against with crossgen2 can also cause this issue. I am not sure what the best way to solve the problem would be.

  1. Accept it
  2. Add some form of versioning to throw away the compilation
  3. Bring back async thunks for this case
  4. Try to compile the async version from the COM interop stub's IL stub
  5. Move the COM interop stub to transient IL and get an async version that way

Copilot AI review requested due to automatic review settings June 23, 2026 13:52

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

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

Comment thread src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs Outdated
Comment thread src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
@jakobbotsch

Copy link
Copy Markdown
Member Author

PTAL @AaronRobinsonMSFT

I'll open a follow up issue about handling the potential versioning problem highlighted above. This fix should at least get outerloop clean.

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

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

@jakobbotsch jakobbotsch merged commit 42f3669 into dotnet:main Jun 25, 2026
119 of 121 checks passed
@jakobbotsch jakobbotsch deleted the fix-129739 branch June 25, 2026 08:43
@teo-tsirpanis teo-tsirpanis removed the area-crossgen2-coreclr only use for closed issues label Jun 25, 2026
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.

Assert failure: IsIL() in TryGenerateAsyncThunk

4 participants