Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Namhyung Kim" <namhyung@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf dwarf-aux: Check .eh_frame section for CFA
Date: Sat, 03 Oct 2026 01:34:18 +0000	[thread overview]
Message-ID: <20261003013419.572481F00898@smtp.kernel.org> (raw)
In-Reply-To: <20261002224242.396135-1-namhyung@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] perf: memory leak of Dwarf_CFI handle in die_get_cfa()
- [Medium] perf: severe performance degradation from repeatedly parsing .eh_frame
--

commit 63cd38e63157cedd873e0aa6adbf63746489d27e
Author: Namhyung Kim <namhyung@kernel.org>

perf dwarf-aux: Check .eh_frame section for CFA

This commit modifies die_get_cfa() to first attempt to retrieve the
.eh_frame section using dwarf_getcfi_elf() before falling back to the
.debug_frame section.

[Severity: Medium]
Does this code leak the dynamically allocated Dwarf_CFI object?

In tools/perf/util/dwarf-aux.c within die_get_cfa(), dwarf_getcfi_elf() is
called to get the .eh_frame section. Unlike dwarf_getcfi(), which returns a
structure owned by the Dwarf context, dwarf_getcfi_elf() allocates a new
Dwarf_CFI object that the caller must free using dwarf_cfi_end().

However, die_get_cfa() returns without freeing the cfi pointer on both the
success path and the error path. Since this function is called repeatedly
during data annotation, could this lead to rapid memory consumption?

[Severity: Medium]
Is there a risk of severe performance degradation here?

Calling dwarf_getcfi_elf() reads and parses the .eh_frame section to
dynamically build a search index for the module. Because die_get_cfa() is a
heavily utilized helper function often called repeatedly, rebuilding this
index and allocating the structures from scratch on every single invocation
could cause massive CPU overhead.

Would it be possible to cache the .eh_frame Dwarf_CFI object to avoid
rebuilding it on every call?

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

      reply	other threads:[~2026-10-03  1:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 22:42 [PATCH] perf dwarf-aux: Check .eh_frame section for CFA Namhyung Kim
2026-10-03  1:34 ` sashiko-bot [this message]

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=20261003013419.572481F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@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