[DTrace-devel] [PATCH] Fix memory leaks
Kris Van Hees
kris.van.hees at oracle.com
Thu Nov 21 18:17:29 UTC 2024
On Thu, Nov 21, 2024 at 01:10:29PM -0500, Eugene Loh via DTrace-devel wrote:
> Reviewed-by: Eugene Loh <eugene.loh at 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?
Sure. Sounds like a good idea.
> With this patch, it also makes sense to remove the "CPC will call
> pfm_terminate()" comment in dtrace_close()
Ah yes, I overlooked that one. Thanks!
> 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 at 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 = {
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list