Re: [PATCH v1 2/3] perf probe: Fix libdw memory leak

From: Namhyung Kim
Date: Wed Oct 02 2024 - 13:44:06 EST


On Mon, Sep 23, 2024 at 5:37 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> Add missing dwarf_cfi_end to free memory associated with probe_finder
> cfi_eh or cfi_dbg. This addresses leak sanitizer issues seen in:
> tools/perf/tests/shell/test_uprobe_from_different_cu.sh
>
> Fixes: 270bde1e76f4 ("perf probe: Search both .eh_frame and .debug_frame sections for probe location")
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> tools/perf/util/probe-finder.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> index 630e16c54ed5..78f34fa0c391 100644
> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -1379,6 +1379,11 @@ int debuginfo__find_trace_events(struct debuginfo *dbg,
> if (ret >= 0 && tf.pf.skip_empty_arg)
> ret = fill_empty_trace_arg(pev, tf.tevs, tf.ntevs);
>
> +#if _ELFUTILS_PREREQ(0, 142)
> + dwarf_cfi_end(tf.pf.cfi_eh);
> + dwarf_cfi_end(tf.pf.cfi_dbg);
> +#endif

This is causing another problem. Now vfs_getname tests are
failing because perf probe aborts.

Thanks,
Namhyung

> +
> if (ret < 0 || tf.ntevs == 0) {
> for (i = 0; i < tf.ntevs; i++)
> clear_probe_trace_event(&tf.tevs[i]);
> --
> 2.46.0.792.g87dc391469-goog
>