Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/9.0-staging] Don't wait for finalizers in 'IReferenceTrackerHost::ReleaseDisconnectedReferenceSources' #110558

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/coreclr/interop/trackerobjectmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading