Skip to content

Commit

Permalink
Bug fixes in BacktraceCommand
Browse files Browse the repository at this point in the history
Summary: In recent changes, forgot to properly check for root nodes in two places. This would cause us not to output trivial lifelines to roots, or crash when outputting backtraces for such situations.

Differential Revision: D55224461

fbshipit-source-id: 157ca71db3e16ee216fa39d26f5f31ed4d26f5fa
  • Loading branch information
elliekorn authored and facebook-github-bot committed Mar 22, 2024
1 parent 73ba785 commit a405776
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions Commands/BacktraceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,24 @@ bool DumpBacktraceLine(int nodeIndex, Dictionary<int, int>? perTypeCounts, HashS
sb.Append(CurrentBacktracer.DescribeNodeIndex(nodeIndex, Output, FullyQualified));

int postorderIndex = CurrentBacktracer.NodeIndexToPostorderIndex(nodeIndex);
int typeIndex = CurrentTracedHeap.PostorderTypeIndexOrSentinel(postorderIndex);
if (typeIndex != -1)
if (postorderIndex != -1)
{
if (perTypeCounts != null)
int typeIndex = CurrentTracedHeap.PostorderTypeIndexOrSentinel(postorderIndex);
if (typeIndex != -1)
{
sb.AppendFormat(" x{0}", perTypeCounts[typeIndex]);
}
if (perTypeCounts != null)
{
sb.AppendFormat(" x{0}", perTypeCounts[typeIndex]);
}

if (Fields)
{
AppendFields(nodeIndex, successorNodeIndex, sb);
}
if (Fields)
{
AppendFields(nodeIndex, successorNodeIndex, sb);
}

NativeWord address = CurrentTracedHeap.PostorderAddress(nodeIndex);
AppendTags(address, sb);
NativeWord address = CurrentTracedHeap.PostorderAddress(nodeIndex);
AppendTags(address, sb);
}
}

Output.AddDisplayStringLineIndented(indent, sb.ToString());
Expand Down Expand Up @@ -239,7 +242,7 @@ bool IsDestination(int nodeIndex)

bool ShouldIgnoreNode(int nodeIndex)
{
if (IgnoreIfAncestorHasTag != null)
if (IgnoreIfAncestorHasTag != null && CurrentBacktracer.IsLiveObjectNode(nodeIndex))
{
// If a tag was given on the command line, stop if the object has that tag.
int postorderIndex = CurrentBacktracer.NodeIndexToPostorderIndex(nodeIndex);
Expand Down

0 comments on commit a405776

Please sign in to comment.