Skip to content

Partially revert PR #125326: revert ComActivator/LicenseInteropProxy changes#125706

Open
Copilot wants to merge 3 commits intomainfrom
copilot/fix-netclientlicense-test-failures
Open

Partially revert PR #125326: revert ComActivator/LicenseInteropProxy changes#125706
Copilot wants to merge 3 commits intomainfrom
copilot/fix-netclientlicense-test-failures

Conversation

Copy link
Contributor

Copilot AI commented Mar 18, 2026

PR #125326 converted LicenseInteropProxy call sites to use [UnmanagedCallersOnly] with raw managed object pointers (object*, Type*, LicenseInteropProxy*). Under GC stress, it is causing heap corruption (exit code -1073740940 / STATUS_HEAP_CORRUPTION).

Fixes #125598

…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
Copilot AI requested a review from jkotas March 18, 2026 03:24
@dotnet-policy-service
Copy link
Contributor

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

@jkotas
Copy link
Member

jkotas commented Mar 18, 2026

/azp run runtime-coreclr gcstress-extra

@jkotas jkotas marked this pull request as ready for review March 18, 2026 03:43
Copilot AI review requested due to automatic review settings March 18, 2026 03:43
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
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

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 LicenseInteropProxy method bindings/signatures and remove pointer-based metasigs.
  • Switch native license interop call sites from UnmanagedCallersOnlyCaller to MethodDescCallSite + ARG_SLOT.
  • Revert CoreLib LicenseInteropProxy back to a managed Create() 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);
@jkotas
Copy link
Member

jkotas commented Mar 18, 2026

/azp run runtime-coreclr gcstress-extra

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

Test failure: Interop/COM/NETClients/Licensing/NETClientLicense/NETClientLicense.cmd

3 participants