From d144cf5566fa7ac4c07183aff7f1b7c301ffa1c6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Jun 2026 13:37:04 +0000 Subject: [PATCH 1/3] Initial plan From 3fca0c413ed319cec0c3a9db76f7bd00281ac18e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Jun 2026 14:21:56 +0000 Subject: [PATCH 2/3] Fix defensive-copy risk for ComWrappers weak handle Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- .../src/System/Runtime/InteropServices/ComWrappers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs index aff669dd7acacc..0c55ea9683cbc4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs @@ -669,7 +669,7 @@ internal sealed class ReferenceTrackerNativeObjectWrapper : NativeObjectWrapper internal readonly IntPtr _contextToken; private int _trackerObjectDisconnected; // Atomic boolean, so using int. private readonly bool _releaseTrackerObject; - internal readonly GCHandle _nativeObjectWrapperWeakHandle; + internal GCHandle _nativeObjectWrapperWeakHandle; public IntPtr TrackerObject => (_trackerObject == IntPtr.Zero || _trackerObjectDisconnected == 1) ? IntPtr.Zero : _trackerObject; From b42d42a9246ce96a2f580ab277c1f030c023137c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 03:42:54 +0000 Subject: [PATCH 3/3] Add ComWrappers weak-handle comment Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com> --- .../src/System/Runtime/InteropServices/ComWrappers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs index 0c55ea9683cbc4..551f84fc1ec3e5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.cs @@ -669,7 +669,7 @@ internal sealed class ReferenceTrackerNativeObjectWrapper : NativeObjectWrapper internal readonly IntPtr _contextToken; private int _trackerObjectDisconnected; // Atomic boolean, so using int. private readonly bool _releaseTrackerObject; - internal GCHandle _nativeObjectWrapperWeakHandle; + internal GCHandle _nativeObjectWrapperWeakHandle; // mutable struct; do not make this readonly public IntPtr TrackerObject => (_trackerObject == IntPtr.Zero || _trackerObjectDisconnected == 1) ? IntPtr.Zero : _trackerObject;