[release/11.0] Fix ComWrappers ICustomQueryInterface exception handling - #132725
Merged
Conversation
Co-authored-by: Jeremy Koritzinsky <Jeremy.Koritzinsky@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
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. |
Contributor
|
Tagging subscribers to this area: @agocke |
This was referenced Aug 25, 2026
jkoritzinsky
requested review from
AaronRobinsonMSFT,
elinor-fung and
jtschuster
August 26, 2026 23:22
jtschuster
approved these changes
Aug 27, 2026
elinor-fung
approved these changes
Aug 27, 2026
Member
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is small, aligns with the native TryInvokeICustomQueryInterfaceResult contract (FailedToInvoke = -1), and directly prevents an assert/crash in the COM QueryInterface path.
Pull request overview
Backports a CoreCLR ComWrappers fix so that exceptions thrown by a managed ICustomQueryInterface.GetInterface implementation are reported to native code as an invocation failure instead of being misinterpreted as “handled”, avoiding a native assert/crash when *ppvObject remains null.
Changes:
- Update
ComWrappers.CoreCLR.csUCO wrapper to return-1(TryInvokeICustomQueryInterfaceResult.FailedToInvoke) from the exception path instead ofdefault(0/Handled).
File summaries
| File | Description |
|---|---|
| src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.CoreCLR.cs | Ensures CallICustomQueryInterface reports FailedToInvoke when the managed call throws, preventing native code from treating the result as Handled with a null out pointer. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #132716 to release/11.0
/cc @jkoritzinsky
Customer Impact
User gets a null object from a
QueryInterfaceagainst a .NET object that implementsICustomQueryInterfaceexposed to COM via ComWrappers that causes theICustomQueryInterfaceimplementation to throw an exceptionRegression
Regressed in #125697
Testing
Caught in outerloop testing
Risk
Low. Targeted scenario and we have testing validation.
IMPORTANT: If this backport is for a servicing release, please verify that:
release/X.0-staging, notrelease/X.0.release/X.0(no-stagingsuffix).Package authoring no longer needed in .NET 9
IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.