public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
From: Eugene Loh <eugene.loh@oracle.com>
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH] Fix memory leaks
Date: Thu, 21 Nov 2024 13:10:29 -0500	[thread overview]
Message-ID: <ea997f1c-1ccc-cce7-d867-e19109bbcf46@oracle.com> (raw)
In-Reply-To: <SJ0PR10MB635051E2F4FFEA4CBE5B3B02C2222@SJ0PR10MB6350.namprd10.prod.outlook.com>

Reviewed-by: Eugene Loh <eugene.loh@oracle.com>

(Oops by me.)

I don't have a good feel for these things, but in dtrace_close() might 
it make more sense to move the free(dt_stmts) to right after the 
dt_program_destroy() loop?

With this patch, it also makes sense to remove the "CPC will call 
pfm_terminate()" comment in dtrace_close()

On 11/21/24 01:40, Kris Van Hees wrote:
> The array of statements was never freed.
> The PFM library data was never cleaned up.
>
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
>   libdtrace/dt_open.c     | 2 ++
>   libdtrace/dt_prov_cpc.c | 1 +
>   2 files changed, 3 insertions(+)
>
> diff --git a/libdtrace/dt_open.c b/libdtrace/dt_open.c
> index e1972aa8..717a7ad0 100644
> --- a/libdtrace/dt_open.c
> +++ b/libdtrace/dt_open.c
> @@ -1314,6 +1314,8 @@ dtrace_close(dtrace_hdl_t *dtp)
>   		free(dirp);
>   	}
>   
> +	free(dtp->dt_stmts);
> +
>   	free(dtp->dt_cpp_argv);
>   	free(dtp->dt_cpp_path);
>   	free(dtp->dt_ld_path);
> diff --git a/libdtrace/dt_prov_cpc.c b/libdtrace/dt_prov_cpc.c
> index 8f33cf58..57b11b13 100644
> --- a/libdtrace/dt_prov_cpc.c
> +++ b/libdtrace/dt_prov_cpc.c
> @@ -484,6 +484,7 @@ static void destroy(dtrace_hdl_t *dtp, void *arg)
>   		dt_free(dtp, probe_map);
>   	}
>   	dt_free(dtp, arg);
> +	pfm_terminate();
>   }
>   
>   dt_provimpl_t	dt_cpc = {

  reply	other threads:[~2024-11-21 18:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21  6:40 [PATCH] Fix memory leaks Kris Van Hees
2024-11-21 18:10 ` Eugene Loh [this message]
2024-11-21 18:17   ` [DTrace-devel] " Kris Van Hees

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=ea997f1c-1ccc-cce7-d867-e19109bbcf46@oracle.com \
    --to=eugene.loh@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@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