Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit d087b29

Browse files
committed
Fix GC.KeepAlive test case
In the test, as written, a GC could sneak in between the GC.KeepAlive() call and the subsequent line that checks whether the finalizer has run, especially in GC stress modes. Simply move the GC.KeepAlive() call down.
1 parent e275d2d commit d087b29

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/src/CoreMangLib/cti/system/gc/gckeepalive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ public bool PosTest1()
4444
GC.WaitForPendingFinalizers();
4545
GC.Collect();
4646

47-
GC.KeepAlive(tc);
4847
if (TestClass.m_TestInt != 1)
4948
{
5049
TestLibrary.TestFramework.LogError("001.1", "Calling KeepAlive can not prevent an object to be GCed");
5150
TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] TestClass.m_TestInt = " + TestClass.m_TestInt);
5251
retVal = false;
5352
}
53+
GC.KeepAlive(tc);
5454
}
5555
catch (Exception e)
5656
{

0 commit comments

Comments
 (0)