Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752845AbdCMOmN (ORCPT ); Mon, 13 Mar 2017 10:42:13 -0400 Received: from mail.kernel.org ([198.145.29.136]:43320 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751119AbdCMOmG (ORCPT ); Mon, 13 Mar 2017 10:42:06 -0400 Date: Mon, 13 Mar 2017 11:41:59 -0300 From: Arnaldo Carvalho de Melo To: changbin.du@intel.com Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf sort: Segmentation fault of basic block cycles sort dimension Message-ID: <20170313144159.GM2750@kernel.org> References: <20170313083148.23568-1-changbin.du@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170313083148.23568-1-changbin.du@intel.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1474 Lines: 44 Em Mon, Mar 13, 2017 at 04:31:48PM +0800, changbin.du@intel.com escreveu: > From: Changbin Du > > 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 Thanks, applied. - Arnaldo > Signed-off-by: Changbin Du > --- > 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