Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 4/7] perf annotate-data: Bound the member nesting recursion
Date: Mon, 21 Sep 2026 16:57:03 +0000	[thread overview]
Message-ID: <20260921165704.38DBD1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921164813.6727-5-acme@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf: primitive fields incorrectly marked as truncated at max depth
--

commit 53c26f5303c3adc8952e84e580aba93503743c50
Author: Arnaldo Carvalho de Melo <acme@redhat.com>

perf annotate-data: Bound the member nesting recursion

This commit introduces a recursion depth limit of 32 when adding members
from DWARF debug information. It prevents infinite recursion caused by
broken DIEs that point back to their own ancestors by marking deep members
as truncated and stopping further parsing.

> diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
> index 2ad6d012e069c..f44fb333bc674 100644
> --- a/tools/perf/util/annotate-data.c
> +++ b/tools/perf/util/annotate-data.c

[ ... ]

> @@ -289,10 +300,19 @@ static int __add_member_cb(Dwarf_Die *die, void *arg)
>  	}
>  	member->size = size;
>  	member->offset = loc + parent->offset;
> +	member->depth = parent->depth + 1;
>  	INIT_LIST_HEAD(&member->children);
>  	list_add_tail(&member->node, &parent->children);
>  
>  	tag = dwarf_tag(&die_mem);
> +	if (member->depth >= MAX_MEMBER_DEPTH) {
> +		/* Reported by the JSON exporter so consumers can tell a truncated tree. */
> +		member->truncated = true;
> +		pr_debug_dtp("member nesting limit reached at %s\n",
> +			     member->type_name ?: "(unknown type)");
> +		return DIE_FIND_CB_SIBLING;
> +	}
> +

[Severity: Medium]
Will this depth check incorrectly flag primitive fields as truncated?

Because this check happens before evaluating the member's DWARF tag, when a
structure at depth 31 is processed, all of its fields reach depth 32.

If one of those fields is a primitive type (like an int) that inherently has
no children, it seems it will still be marked with member->truncated = true
and trigger the pr_debug_dtp() log.

Should this depth limit evaluation happen after confirming the member is an
aggregate type (like a structure or union) that actually has children to
expand?

>  	switch (tag) {
>  	case DW_TAG_structure_type:
>  	case DW_TAG_union_type:
>  		die_find_child(&die_mem, __add_member_cb, member, &die_mem);
>  		break;
>  	default:
>  		break;
>  	}
>  	return DIE_FIND_CB_SIBLING;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260921164813.6727-1-acme@kernel.org?part=4

  reply	other threads:[~2026-09-21 16:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 16:48 [PATCH v2 0/7] perf annotate-data: Fix hangs on broken debug info, data type browser sample count, AMD mem record Arnaldo Carvalho de Melo
2026-09-21 16:48 ` [PATCH 1/7] perf dwarf-aux: Bound the type chases for broken debug info Arnaldo Carvalho de Melo
2026-09-21 16:56   ` sashiko-bot
2026-09-21 16:48 ` [PATCH 2/7] perf dwarf-aux: Add die_same_file() and die_get_type_die() Arnaldo Carvalho de Melo
2026-09-21 16:56   ` sashiko-bot
2026-09-21 16:48 ` [PATCH 3/7] perf annotate-data: Resolve type DIEs in the debug file they came from Arnaldo Carvalho de Melo
2026-09-21 16:57   ` sashiko-bot
2026-09-21 16:48 ` [PATCH 4/7] perf annotate-data: Bound the member nesting recursion Arnaldo Carvalho de Melo
2026-09-21 16:57   ` sashiko-bot [this message]
2026-09-21 16:48 ` [PATCH 5/7] perf annotate-data: Show the sample count in the data-type browser Arnaldo Carvalho de Melo
2026-09-21 16:55   ` sashiko-bot
2026-09-21 16:48 ` [PATCH 6/7] perf mem record: Request PERF_SAMPLE_CPU by default Arnaldo Carvalho de Melo
2026-09-21 16:55   ` sashiko-bot
2026-09-21 16:48 ` [PATCH 7/7] perf mem record: Use the IBS swfilt filter when available Arnaldo Carvalho de Melo
2026-09-21 16:58   ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-09-19 20:40 [PATCH 0/7] perf annotate-data: Fix hangs on broken debug info, data type browser sample count, AMD mem record Arnaldo Carvalho de Melo
2026-09-19 20:40 ` [PATCH 4/7] perf annotate-data: Bound the member nesting recursion Arnaldo Carvalho de Melo
2026-09-19 20:46   ` sashiko-bot
2026-09-21  6:22   ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260921165704.38DBD1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acme@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox