public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: jolsa@redhat.com, alexander.shishkin@linux.intel.com,
	namhyung@kernel.org, dsahern@gmail.com, davidcc@google.com,
	ak@linux.intel.com, yao.jin@linux.intel.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] perf script: Fix crash because of missing evsel->priv
Date: Wed, 20 Jun 2018 10:52:20 -0300	[thread overview]
Message-ID: <20180620135220.GP20477@kernel.org> (raw)
In-Reply-To: <20180620133030.2188-3-ravi.bangoria@linux.ibm.com>

Em Wed, Jun 20, 2018 at 07:00:29PM +0530, Ravi Bangoria escreveu:
> perf script in pipped mode is crashing because evsel->priv is not
> set properly. Fix it.
> 
> Before:
>   # ./perf record -o - -- ls | ./perf script
>     Segmentation fault (core dumped)
> 
> After:
>   # ./perf record -o - -- ls | ./perf script
>   ls 2282 1031.731974:  250000 cpu-clock:uhH:  7effe4b3d29e
>   ls 2282 1031.732222:  250000 cpu-clock:uhH:  7effe4b3a650
> 
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> Fixes: a14390fde64e ("perf script: Allow creating per-event dump files")

Humm, this cset doesn't set evsel->priv to a 'struct perf_evsel_script'
object, will check which one does to continue review.

- Arnaldo

> ---
>  tools/perf/builtin-script.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 4d1cee68cfd2..acee05562f5e 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -1822,6 +1822,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
>  	struct perf_evlist *evlist;
>  	struct perf_evsel *evsel, *pos;
>  	int err;
> +	static struct perf_evsel_script *es;
>  
>  	err = perf_event__process_attr(tool, event, pevlist);
>  	if (err)
> @@ -1830,6 +1831,19 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
>  	evlist = *pevlist;
>  	evsel = perf_evlist__last(*pevlist);
>  
> +	if (!evsel->priv) {
> +		if (scr->per_event_dump) {
> +			evsel->priv = perf_evsel_script__new(evsel,
> +						scr->session->data);
> +		} else {
> +			es = zalloc(sizeof(*es));
> +			if (!es)
> +				return -ENOMEM;
> +			es->fp = stdout;
> +			evsel->priv = es;
> +		}
> +	}
> +
>  	if (evsel->attr.type >= PERF_TYPE_MAX &&
>  	    evsel->attr.type != PERF_TYPE_SYNTH)
>  		return 0;
> -- 
> 2.14.4

  reply	other threads:[~2018-06-20 13:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-20 13:30 [PATCH 0/3] perf script: Few trivial fixes Ravi Bangoria
2018-06-20 13:30 ` [PATCH 1/3] perf script: Add missing output fields in a hint Ravi Bangoria
2018-06-20 13:30 ` [PATCH 2/3] perf script: Fix crash because of missing evsel->priv Ravi Bangoria
2018-06-20 13:52   ` Arnaldo Carvalho de Melo [this message]
2018-06-20 14:00     ` Ravi Bangoria
2018-06-22  3:53     ` Ravi Bangoria
2018-06-20 13:30 ` [PATCH 3/3] perf script: Fix crash because of missing feat_op[] entry Ravi Bangoria
2018-06-20 13:49   ` Arnaldo Carvalho de Melo
2018-06-20 14:09     ` Ravi Bangoria

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=20180620135220.GP20477@kernel.org \
    --to=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=davidcc@google.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=yao.jin@linux.intel.com \
    /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