Re: [PATCH] perf report: Fix a memory corrupton issue when enabling --branch-history

From: Jiri Olsa
Date: Fri Feb 16 2018 - 02:53:26 EST


On Fri, Feb 16, 2018 at 10:25:31AM +0800, Jin, Yao wrote:

SNIP

> > From my opinion, the option '--max-stack' in perf report looks not very
> > necessary. While it's just my personal opinion, need to hear from more
> > people. :)
> >
> > Thanks
> > Jin Yao
> >
> > > thanks,
> > > jirka
> > >
> > >
> > > ---
> > > diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
> > > index b6140950301e..b50b7b70dcca 100644
> > > --- a/tools/perf/util/hist.c
> > > +++ b/tools/perf/util/hist.c
> > > @@ -879,7 +879,7 @@ iter_prepare_cumulative_entry(struct
> > > hist_entry_iter *iter,
> > >        * cumulated only one time to prevent entries more than 100%
> > >        * overhead.
> > >        */
> > > -    he_cache = malloc(sizeof(*he_cache) * (iter->max_stack + 1));
> > > +    he_cache = malloc(sizeof(*he_cache) * (callchain_cursor.nr + 1));
> > >       if (he_cache == NULL)
> > >           return -ENOMEM;
> > >
>
> Hi Jiri,
>
> I guess you will post this patch, right?

yep, later today

jirka