Skip to content

Commit

Permalink
Fix gc hole in Frozen.cs (#76868)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
  • Loading branch information
EgorBo and jkotas committed Oct 11, 2022
1 parent e139ffb commit af63f60
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/tests/GC/API/Frozen/Frozen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,9 @@ internal class Node

internal static class Program
{
private static unsafe IntPtr GetMethodTablePointer(object obj)
{
GCHandle gch = GCHandle.Alloc(obj);
IntPtr pointerToPointerToObject = GCHandle.ToIntPtr(gch);
IntPtr pointerToObject = *((IntPtr*)pointerToPointerToObject);
IntPtr methodTable = *((IntPtr*)pointerToObject);
gch.Free();
return methodTable;
}

private static unsafe int Main(string[] args)
{
Node template = new Node();
IntPtr methodTable = GetMethodTablePointer(template);
IntPtr methodTable = typeof(Node).TypeHandle.Value;

FrozenSegmentBuilder frozenSegmentBuilder = new FrozenSegmentBuilder(1000);
IntPtr node1Ptr = frozenSegmentBuilder.Allocate(methodTable);
Expand Down

0 comments on commit af63f60

Please sign in to comment.