We need to determine that an object finalizer has not been run
*before* the KeepAlive call. After the call, it is perfectly
valid for the finalizer to be called, which can happen under
GCStress.
Commit migrated from https://github.com/dotnet/coreclr/commit/
75623f73d1fd635ddace9d36ee28eeabe6030531
}
- public static void RunTest()
+ public static bool RunTest()
{
+ bool success = false;
+
Dummy obj = new Dummy();
RunTest2();
GC.Collect();
//}
+ success = (visited1 == false) && (visited2 == true);
+
GC.KeepAlive(obj); // will keep obj alive until this point
+
+ return success;
}
public static int Main()
{
- RunTest();
+ bool success = RunTest();
- if ((visited1 == false) && (visited2 == true))
+ if (success)
{
Console.WriteLine("Test for KeepAlive() passed!");
return 100;
else
{
Console.WriteLine("Test for KeepAlive() failed!");
-
-
return 1;
}
}