[v4,04/22] perf test: Fix memory leak in symbols

Message ID 20230320033810.980165-5-irogers@google.com
State New
Headers
Series Reference count checker and related fixes |

Commit Message

Ian Rogers March 20, 2023, 3:37 a.m. UTC
  machine__delete doesn't delete threads. Add call to delete threads
ahead of deleting the machine.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/symbols.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Adrian Hunter March 20, 2023, 8:06 a.m. UTC | #1
On 20/03/23 05:37, Ian Rogers wrote:
> machine__delete doesn't delete threads.

Which begs the question: Shouldn't it?

>                                         Add call to delete threads
> ahead of deleting the machine.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/tests/symbols.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/perf/tests/symbols.c b/tools/perf/tests/symbols.c
> index 057b16df6416..0793f8f419e2 100644
> --- a/tools/perf/tests/symbols.c
> +++ b/tools/perf/tests/symbols.c
> @@ -38,6 +38,7 @@ static int init_test_info(struct test_info *ti)
>  static void exit_test_info(struct test_info *ti)
>  {
>  	thread__put(ti->thread);
> +	machine__delete_threads(ti->machine);
>  	machine__delete(ti->machine);
>  }
>
  
Ian Rogers March 20, 2023, 1:04 p.m. UTC | #2
On Mon, Mar 20, 2023 at 1:06 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 20/03/23 05:37, Ian Rogers wrote:
> > machine__delete doesn't delete threads.
>
> Which begs the question: Shouldn't it?

Agreed. The patch set was already large enough so I think this can be
followed up separately.

Thanks,
Ian

> >                                         Add call to delete threads
> > ahead of deleting the machine.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  tools/perf/tests/symbols.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/tools/perf/tests/symbols.c b/tools/perf/tests/symbols.c
> > index 057b16df6416..0793f8f419e2 100644
> > --- a/tools/perf/tests/symbols.c
> > +++ b/tools/perf/tests/symbols.c
> > @@ -38,6 +38,7 @@ static int init_test_info(struct test_info *ti)
> >  static void exit_test_info(struct test_info *ti)
> >  {
> >       thread__put(ti->thread);
> > +     machine__delete_threads(ti->machine);
> >       machine__delete(ti->machine);
> >  }
> >
>
  

Patch

diff --git a/tools/perf/tests/symbols.c b/tools/perf/tests/symbols.c
index 057b16df6416..0793f8f419e2 100644
--- a/tools/perf/tests/symbols.c
+++ b/tools/perf/tests/symbols.c
@@ -38,6 +38,7 @@  static int init_test_info(struct test_info *ti)
 static void exit_test_info(struct test_info *ti)
 {
 	thread__put(ti->thread);
+	machine__delete_threads(ti->machine);
 	machine__delete(ti->machine);
 }