Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/src/CoreMangLib/cti/system/gc/gckeepalive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public bool PosTest1()
GC.WaitForPendingFinalizers();
GC.Collect();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern is known to be flaky. I addressed a few tests that rely on this pattern here: #11216. If this test isn't flaky, I don't think there's any reason to address it here, but as it's written it's possible for the test to fail if we take a really unlucky path through the scheduler.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. No, flakiness isn't the issue I was seeing; it's that the lifetime of tc was simply incorrect.


GC.KeepAlive(tc);
if (TestClass.m_TestInt != 1)
{
TestLibrary.TestFramework.LogError("001.1", "Calling KeepAlive can not prevent an object to be GCed");
TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] TestClass.m_TestInt = " + TestClass.m_TestInt);
retVal = false;
}
GC.KeepAlive(tc);
}
catch (Exception e)
{
Expand Down