Re: [PATCH 05/11] perf parse-event: Fix memory leak in evsel->unit

2020-09-16 Thread Ian Rogers
On Wed, Sep 16, 2020 at 12:12 AM Namhyung Kim wrote: > > Hello Ian and David, > > Thank you for the good suggestions! > > On Wed, Sep 16, 2020 at 4:56 AM David Malcolm wrote: > > Some ideas (with the caveat that I'm a GCC developer, and not a regular > > on LKML): can you capture the ownership st

Re: [PATCH 05/11] perf parse-event: Fix memory leak in evsel->unit

2020-09-16 Thread Namhyung Kim
Hello Ian and David, Thank you for the good suggestions! On Wed, Sep 16, 2020 at 4:56 AM David Malcolm wrote: > Some ideas (with the caveat that I'm a GCC developer, and not a regular > on LKML): can you capture the ownership status in the type system? > I'm brainstorming here but how about: >

Re: [PATCH 05/11] perf parse-event: Fix memory leak in evsel->unit

2020-09-15 Thread Arnaldo Carvalho de Melo
Em Tue, Sep 15, 2020 at 11:59:13AM -0700, Ian Rogers escreveu: > On Tue, Sep 15, 2020 at 5:19 AM Arnaldo Carvalho de Melo > wrote: > > > > Em Tue, Sep 15, 2020 at 12:18:13PM +0900, Namhyung Kim escreveu: > > > The evsel->unit borrows a pointer of pmu event or alias instead of > > > owns a string.

Re: [PATCH 05/11] perf parse-event: Fix memory leak in evsel->unit

2020-09-15 Thread David Malcolm
On Tue, 2020-09-15 at 11:59 -0700, Ian Rogers wrote: > On Tue, Sep 15, 2020 at 5:19 AM Arnaldo Carvalho de Melo > wrote: > > Em Tue, Sep 15, 2020 at 12:18:13PM +0900, Namhyung Kim escreveu: > > > The evsel->unit borrows a pointer of pmu event or alias instead > > > of > > > owns a string. But too

Re: [PATCH 05/11] perf parse-event: Fix memory leak in evsel->unit

2020-09-15 Thread Ian Rogers
On Tue, Sep 15, 2020 at 5:19 AM Arnaldo Carvalho de Melo wrote: > > Em Tue, Sep 15, 2020 at 12:18:13PM +0900, Namhyung Kim escreveu: > > The evsel->unit borrows a pointer of pmu event or alias instead of > > owns a string. But tool event (duration_time) passes a result of > > strdup() caused a le

Re: [PATCH 05/11] perf parse-event: Fix memory leak in evsel->unit

2020-09-15 Thread Arnaldo Carvalho de Melo
Em Tue, Sep 15, 2020 at 12:18:13PM +0900, Namhyung Kim escreveu: > The evsel->unit borrows a pointer of pmu event or alias instead of > owns a string. But tool event (duration_time) passes a result of > strdup() caused a leak. > > It was found by ASAN during metric test: Thanks, applied. > D

[PATCH 05/11] perf parse-event: Fix memory leak in evsel->unit

2020-09-14 Thread Namhyung Kim
The evsel->unit borrows a pointer of pmu event or alias instead of owns a string. But tool event (duration_time) passes a result of strdup() caused a leak. It was found by ASAN during metric test: Direct leak of 210 byte(s) in 70 object(s) allocated from: #0 0x7fe366fca0b5 in strdup (/lib/