diff --git a/src/coreclr/interop/trackerobjectmanager.cpp b/src/coreclr/interop/trackerobjectmanager.cpp index d4302054baedba..0df78164906dcc 100644 --- a/src/coreclr/interop/trackerobjectmanager.cpp +++ b/src/coreclr/interop/trackerobjectmanager.cpp @@ -84,7 +84,10 @@ namespace STDMETHODIMP HostServices::ReleaseDisconnectedReferenceSources() { - return InteropLibImports::WaitForRuntimeFinalizerForExternal(); + // We'd like to call InteropLibImports::WaitForRuntimeFinalizerForExternal() here, but this could + // lead to deadlock if the finalizer thread is trying to get back to this thread, because we are + // not pumping anymore. Disable this for now. See: https://github.com/dotnet/runtime/issues/109538. + return S_OK; } STDMETHODIMP HostServices::NotifyEndOfReferenceTrackingOnThread() diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs index cc33e85d73917c..b4d70b66c2a937 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs @@ -1418,15 +1418,10 @@ internal static unsafe int IReferenceTrackerHost_DisconnectUnusedReferenceSource [UnmanagedCallersOnly] internal static unsafe int IReferenceTrackerHost_ReleaseDisconnectedReferenceSources(IntPtr pThis) { - try - { - GC.WaitForPendingFinalizers(); - return HResults.S_OK; - } - catch (Exception e) - { - return Marshal.GetHRForException(e); - } + // We'd like to call GC.WaitForPendingFinalizers() here, but this could lead to deadlock + // if the finalizer thread is trying to get back to this thread, because we are not pumping + // anymore. Disable this for now. See: https://github.com/dotnet/runtime/issues/109538. + return HResults.S_OK; } [UnmanagedCallersOnly]