From: changbin.du@intel.com
To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org
Cc: linux-kernel@vger.kernel.org, Changbin Du <changbin.du@intel.com>
Subject: [PATCH] perf sort: Segmentation fault of basic block cycles sort dimension
Date: Mon, 13 Mar 2017 16:31:48 +0800 [thread overview]
Message-ID: <20170313083148.23568-1-changbin.du@intel.com> (raw)
From: Changbin Du <changbin.du@intel.com>
Skip the sample which doesn't have branch_info to avoid segmentation
fault occurrence.
The fault can be reproduced by:
perf record -a
perf report -F cycles
Signed-off-by: Changbin Du <changbin.du@intel.com>
---
tools/perf/util/sort.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 0ff6222..b6db140 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -846,6 +846,9 @@ static int hist_entry__mispredict_snprintf(struct hist_entry *he, char *bf,
static int64_t
sort__cycles_cmp(struct hist_entry *left, struct hist_entry *right)
{
+ if (!left->branch_info || !right->branch_info)
+ return cmp_null(left->branch_info, right->branch_info);
+
return left->branch_info->flags.cycles -
right->branch_info->flags.cycles;
}
@@ -853,6 +856,8 @@ sort__cycles_cmp(struct hist_entry *left, struct hist_entry *right)
static int hist_entry__cycles_snprintf(struct hist_entry *he, char *bf,
size_t size, unsigned int width)
{
+ if (!he->branch_info)
+ return scnprintf(bf, size, "%-.*s", width, "N/A");
if (he->branch_info->flags.cycles == 0)
return repsep_snprintf(bf, size, "%-*s", width, "-");
return repsep_snprintf(bf, size, "%-*hd", width,
--
2.7.4
next reply other threads:[~2017-03-13 8:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-13 8:31 changbin.du [this message]
2017-03-13 14:41 ` [PATCH] perf sort: Segmentation fault of basic block cycles sort dimension Arnaldo Carvalho de Melo
2017-03-15 18:37 ` [tip:perf/core] perf sort: Fix segfault with basic block 'cycles' " tip-bot for Changbin Du
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=20170313083148.23568-1-changbin.du@intel.com \
--to=changbin.du@intel.com \
--cc=acme@kernel.org \
--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