Remove `readonly` from GCHandle field on Gen2GcCallback (dotnet/coreclr#26509)
authorStephen Toub <stoub@microsoft.com>
Wed, 4 Sep 2019 15:58:36 +0000 (11:58 -0400)
committerJan Kotas <jkotas@microsoft.com>
Wed, 4 Sep 2019 15:58:36 +0000 (08:58 -0700)
GCHandle is mutable, and this type does call Free on the handle, but with it marked as readonly, the mutations performed by Free will be done on a copy rather than on the original.

Commit migrated from https://github.com/dotnet/coreclr/commit/85bec20cfeed5d364f7298d94fa37ca11f0accff

src/libraries/System.Private.CoreLib/src/System/Gen2GcCallback.cs

index f1a9c25..1926f6f 100644 (file)
@@ -16,7 +16,7 @@ namespace System
     {
         private readonly Func<bool>? _callback0;
         private readonly Func<object, bool>? _callback1;
-        private readonly GCHandle _weakTargetObj;
+        private GCHandle _weakTargetObj;
 
         private Gen2GcCallback(Func<bool> callback)
         {