Starting with .NET 10 I cannot find root paths anymore.
I created a small repro where I open a dump and try to find this well-known object (obj in the example) that is held in a static field of type List.
If I walk the references starting from the static field, I reach the object, therefore the dump is ok. But if I try the code below (which I took from the GCRoot demo and is supposed to walk backwards the tree), it does not find anything.
I read this note in a comment of GCRoot but I do not believe it is the culprit
// On .NET 10+ statics live in a single Object[] handle and stack roots may not include locals, so
// without these handles only 1 root path would exist.
Am I doing anything wrong?
private void EnumPathv3(ClrHeap heap, ClrObject obj)
{
var targetAddress = obj.Address;
GCRoot gcroot = new(heap, [targetAddress]);
foreach ((ClrRoot root, GCRoot.ChainLink path) in gcroot.EnumerateRootPaths())
{
Console.Write($"{root} -> ");
// Walk the chain of objects from the root to the target.
GCRoot.ChainLink? link = path;
while (link is not null)
{
Console.Write($"{link.Object:x}");
link = link.Next;
if (link is not null)
Console.Write(" -> ");
}
Console.WriteLine();
}
}
Starting with .NET 10 I cannot find root paths anymore.
I created a small repro where I open a dump and try to find this well-known object (
objin the example) that is held in a static field of type List.If I walk the references starting from the static field, I reach the object, therefore the dump is ok. But if I try the code below (which I took from the GCRoot demo and is supposed to walk backwards the tree), it does not find anything.
I read this note in a comment of
GCRootbut I do not believe it is the culpritAm I doing anything wrong?