mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Chris Phlipot <cphlipot0@gmail.com>
Cc: mingo@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf script: fix segfault when printing callchains using builtin-script
Date: Wed, 20 Apr 2016 00:04:56 -0300	[thread overview]
Message-ID: <20160420030456.GJ3677@kernel.org> (raw)
In-Reply-To: <1461119531-2529-1-git-send-email-cphlipot0@gmail.com>

Em Tue, Apr 19, 2016 at 07:32:11PM -0700, Chris Phlipot escreveu:
> This fixes a bug caused by an unitialized callchain cursor. The crash
> frist appeared in:
> 6f736735e30f ("perf evsel: Require that callchains be resolved before
> calling fprintf_{sym,callchain}")
> 
> The callchain cursor is a struct that contains pointers, that when
> uninitialized will cause unpredictable behavior (usually a crash)
> when trying to append to the callchain.
> 
> The existing implementation has the following issues:
> 1. The callchain cursor used is not initialized, resulting in
> 	unpredictable behavior when used.
> 2. The cursor is declared on the stack. Even if it is properly initalized,
> 	the implmentation will leak memory when the function returns,
> 	since all the references to the callchain_nodes allocated by
> 	callchain_cursor_append will be lost when the cursor goes out of
> 	scope.
> 3. Storing the cursor on the stack is inefficient. Even if memory is
> 	properly freed when it goes out of scope, a performance penalty
> 	will be incurred due to reallocation of callchain nodes.
> 	callchain_cursor_append is designed to avoid these reallocations
> 	when an existing cursor is reused.
> 
> This patch fixes the crash by replacing cursor_callchain with a reference
> to the global callchain_cursor which also resolves all 3 issues mentioned
> above.
> 
> How to reproduce the crash:
> $ perf record --call-graph=dwarf stress -t 1 -c 1
> $ perf script > /dev/null
> Segfault

My bad, applying the patch, thanks!

- Arnaldo

  reply	other threads:[~2016-04-20  3:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-20  2:32 Chris Phlipot
2016-04-20  3:04 ` Arnaldo Carvalho de Melo [this message]
2016-04-27 15:30 ` [tip:perf/core] perf script: Fix segfault when printing callchains tip-bot for Chris Phlipot

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=20160420030456.GJ3677@kernel.org \
    --to=acme@kernel.org \
    --cc=cphlipot0@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /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

Powered by JetHome