From 825b20fd2bca346c26e71e71fbe533e49e91fb5a Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 16 Oct 2019 03:51:21 +0200 Subject: [PATCH] Disable finalization of bogus SafeWaitHandles (dotnet/corefx#41801) Fixes https://github.com/dotnet/corefx/issues/41635#issuecomment-542409299. Commit migrated from https://github.com/dotnet/corefx/commit/b50bd0a1d3f0326fc717706cb5c5950ab41cf437 --- src/libraries/System.Runtime.Handles/tests/SafeWaitHandleExtensions.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/System.Runtime.Handles/tests/SafeWaitHandleExtensions.cs b/src/libraries/System.Runtime.Handles/tests/SafeWaitHandleExtensions.cs index 99b5797..da51086 100644 --- a/src/libraries/System.Runtime.Handles/tests/SafeWaitHandleExtensions.cs +++ b/src/libraries/System.Runtime.Handles/tests/SafeWaitHandleExtensions.cs @@ -41,6 +41,9 @@ public partial class SafeWaitHandleExtensionsTests swh = wh.GetSafeWaitHandle(); Assert.NotNull(swh); Assert.Equal(new IntPtr(-1), swh.DangerousGetHandle()); + + // Prevent finalization. Closing of the bogus handle has unpredictable results. + swhExpected.SetHandleAsInvalid(); } [Fact] -- 2.7.4