From 40201e6a6c261e1d6537e2e87107f402ed2b2e7d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 10 Feb 2025 17:26:03 -0800 Subject: [PATCH] Wait to complete the test before releasing the agile reference. Otherwise we can end up with a use-after-free --- src/tests/Interop/COM/ComWrappers/API/Program.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tests/Interop/COM/ComWrappers/API/Program.cs b/src/tests/Interop/COM/ComWrappers/API/Program.cs index 8204ce75f6a903..a87ba2e79a6906 100644 --- a/src/tests/Interop/COM/ComWrappers/API/Program.cs +++ b/src/tests/Interop/COM/ComWrappers/API/Program.cs @@ -1084,6 +1084,7 @@ public unsafe void CrossApartmentQueryInterface_NoDeadlock() staThread.Start(); mtaThread.Start(); + testCompleted.WaitOne(); } finally { @@ -1092,8 +1093,6 @@ public unsafe void CrossApartmentQueryInterface_NoDeadlock() Marshal.Release(agileReference); } } - - testCompleted.WaitOne(); } [DllImport("ole32.dll")]