Skip to content

Move Untracked_Release to native code to avoid problems during shutdown #115489

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

Merged
merged 3 commits into from
May 13, 2025

Conversation

jkoritzinsky
Copy link
Member

@jkoritzinsky jkoritzinsky commented May 12, 2025

Fixes #115460
Fixes #115462

Copy link
Contributor

@Copilot 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

This PR moves the implementation of untracked COM reference counting from managed to native code to avoid problems during process shutdown. Key changes include:

  • Updating ReferenceTrackerHost.cs to call a native provider for AddRef/Release.
  • Removing managed implementations of Untracked_AddRef/Untracked_Release from ComWrappers.cs.
  • Adding native implementations and entrypoints in multiple interop and runtime files.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
System/Runtime/InteropServices/ReferenceTrackerHost.cs Updated to use native function pointers via GetUntrackedIUnknownImpl
System/Runtime/InteropServices/ComWrappers.cs Removed managed implementations of untracked ref counting
vm/qcallentrypoints.cpp Added entries for native untracked AddRef/Release
vm/interoplibinterface_comwrappers.h Declared native functions for untracked AddRef/Release
vm/interoplibinterface_comwrappers.cpp Defined native implementations for untracked AddRef/Release and exposed them
nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs Added extern declaration for RhUntracked_Release
nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/TrackerObjectManager.NativeAot.cs Updated to use the native GetUntrackedIUnknownImpl pattern
nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs Added a native GetUntrackedIUnknownImpl method to acquire function pointers
nativeaot/Runtime/HandleTableHelpers.cpp Implemented native RhUntracked_Release to avoid GC transitions during shutdown
System/Runtime/InteropServices/ComWrappers.CoreCLR.cs Added native imports for untracked AddRef/Release

Copy link
Contributor

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

@jkoritzinsky
Copy link
Member Author

/ba-g failures unrelated

@jkoritzinsky jkoritzinsky merged commit c8465dd into dotnet:main May 13, 2025
138 of 143 checks passed
@jkoritzinsky jkoritzinsky deleted the no-release-during-shutdown branch May 13, 2025 02:15
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants