Partially revert PR #125326: revert ComActivator/LicenseInteropProxy changes#125706
Open
Partially revert PR #125326: revert ComActivator/LicenseInteropProxy changes#125706
Conversation
…changes The [UnmanagedCallersOnly] approach for LicenseInteropProxy was causing heap corruption (STATUS_HEAP_CORRUPTION) under GC stress scenarios. Revert to the original MethodDescCallSite-based approach. Changes: - ComActivator.cs: Restore public static object Create() and remove the unsafe [UnmanagedCallersOnly] static methods for GetCurrentContextInfo and SaveKeyInCurrentContext - corelib.h: Restore original LICENSE_INTEROP_PROXY method signatures (SM_RetObj, IM_RuntimeTypeHandle_RefBool_RefIntPtr_RetVoid, IM_IntPtr_RetVoid) - runtimecallablewrapper.cpp: Restore MethodDescCallSite calls for license interop - metasig.h: Remove added PtrLicenseInteropProxy_* metasig definitions Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [runtime-coreclr] Fix test failure in NETClientLicense
Partially revert PR #125326: revert ComActivator/LicenseInteropProxy changes
Mar 18, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/interop-contrib |
Member
|
/azp run runtime-coreclr gcstress-extra |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Partially reverts PR #125326 for COM licensing activation by restoring GC-safe managed-call patterns for LicenseInteropProxy, addressing heap corruption under GC stress.
Changes:
- Restore
LicenseInteropProxymethod bindings/signatures and remove pointer-based metasigs. - Switch native license interop call sites from
UnmanagedCallersOnlyCallertoMethodDescCallSite+ARG_SLOT. - Revert CoreLib
LicenseInteropProxyback to a managedCreate()factory and remove unsafe[UnmanagedCallersOnly]wrappers.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/coreclr/vm/runtimecallablewrapper.cpp | Replaces UCO pointer calls with MethodDescCallSite invocations for license interop. |
| src/coreclr/vm/metasig.h | Removes metasig entries for pointer-based LicenseInteropProxy UCO signatures. |
| src/coreclr/vm/corelib.h | Restores original method binding signatures for LicenseInteropProxy. |
| src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs | Restores managed Create() and removes unsafe UCO wrappers for licensing methods. |
Comment on lines
142
to
+153
| gc.pType = rth.GetManagedClassObject(); | ||
|
|
||
| // Query the current licensing context | ||
| UnmanagedCallersOnlyCaller getCurrentContextInfo(METHOD__LICENSE_INTEROP_PROXY__GETCURRENTCONTEXTINFO); | ||
| MethodDescCallSite getCurrentContextInfo(METHOD__LICENSE_INTEROP_PROXY__GETCURRENTCONTEXTINFO, &gc.pProxy); | ||
| CLR_BOOL fDesignTime = FALSE; | ||
| INT_PTR bstrKeyRaw = NULL; | ||
| getCurrentContextInfo.InvokeThrowing(&gc.pProxy, &gc.pType, &fDesignTime, &bstrKeyRaw); | ||
| bstrKey = (BSTR)bstrKeyRaw; | ||
| ARG_SLOT args[4]; | ||
| args[0] = ObjToArgSlot(gc.pProxy); | ||
| args[1] = ObjToArgSlot(gc.pType); | ||
| args[2] = (ARG_SLOT)&fDesignTime; | ||
| args[3] = (ARG_SLOT)(BSTR*)&bstrKey; | ||
|
|
||
| getCurrentContextInfo.Call(args); |
Comment on lines
+147
to
+153
| ARG_SLOT args[4]; | ||
| args[0] = ObjToArgSlot(gc.pProxy); | ||
| args[1] = ObjToArgSlot(gc.pType); | ||
| args[2] = (ARG_SLOT)&fDesignTime; | ||
| args[3] = (ARG_SLOT)(BSTR*)&bstrKey; | ||
|
|
||
| getCurrentContextInfo.Call(args); |
Comment on lines
+186
to
+188
| args[0] = ObjToArgSlot(gc.pProxy); | ||
| args[1] = (ARG_SLOT)(BSTR)bstrKey; | ||
| saveKeyInCurrentContext.Call(args); |
Member
|
/azp run runtime-coreclr gcstress-extra |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Mar 18, 2026
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.
main PR #125326
Description
PR #125326 converted
LicenseInteropProxycall sites to use[UnmanagedCallersOnly]with raw managed object pointers (object*,Type*,LicenseInteropProxy*). Under GC stress, the collector can move objects between pin points, invalidating those pointers and causing heap corruption (exit code-1073740940/STATUS_HEAP_CORRUPTION).Reverts only the
LicenseInteropProxy-related changes; other conversions in that PR are left intact.ComActivator.cs: Restorepublic static object Create()returning a newLicenseInteropProxy; remove unsafe[UnmanagedCallersOnly]static wrappers forGetCurrentContextInfoandSaveKeyInCurrentContextcorelib.h: Restore original method binding signatures —SM_RetObj,IM_RuntimeTypeHandle_RefBool_RefIntPtr_RetVoid,IM_IntPtr_RetVoidruntimecallablewrapper.cpp: ReplaceUnmanagedCallersOnlyCallerwith GC-safeMethodDescCallSite+ARG_SLOTfor all three license interop call sitesmetasig.h: Remove the twoPtrLicenseInteropProxy_*metasig entries no longer referencedCustomer Impact
NETClientLicensetest crashes under all GC stress modes on Windows x86 and x64. Any application using COM licensed object activation viaIClassFactory2is at risk of heap corruption at runtime.Regression
Yes — introduced by PR #125326.
Testing
Covered by the existing
Interop/COM/NETClients/Licensing/NETClientLicensetest, which consistently fails undergcstress0xc_*configurations without this fix.Risk
Low. This is a targeted revert to well-understood, previously-working code paths. The
MethodDescCallSitepattern is the established GC-safe mechanism for calling managed methods from native code; no new logic is introduced.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.
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.