Skip to content

Commit

Permalink
Fix GC liveness check in ByRefLocals test
Browse files Browse the repository at this point in the history
  • Loading branch information
CarolEidt committed Aug 14, 2020
1 parent 3873bf5 commit ffc9de0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/tests/Loader/CollectibleAssemblies/ByRefLocals/ByRefLocals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@ static int HoldAssembliesAliveThroughByRefFields(out GCHandle gch1, out GCHandle
Console.WriteLine(span2[0]);
GC.Collect(2);
GC.WaitForPendingFinalizers();
if (gch1.Target == null)
// The loop may be unrolled, in which case things won't be live on the final iteration.
if (i < 9)
{
return 1;
}
if (gch2.Target == null)
{
return 2;
if (gch1.Target == null)
{
return 1;
}
if (gch2.Target == null)
{
return 2;
}
}
}

Expand Down Expand Up @@ -110,4 +114,4 @@ private static ReadOnlySpan<byte> CreateAssemblyDynamically(out GCHandle gchToAs
return spanAccessor.GetSpan();
}

}
}

0 comments on commit ffc9de0

Please sign in to comment.