Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1598940 > unrolled thread

[PATCH] perf sort: Segmentation fault of basic block cycles sort dimension

Started bychangbin.du@intel.com
First post2017-03-13 09:40 +0100
Last post2017-03-13 15:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf sort: Segmentation fault of basic block cycles sort dimension changbin.du@intel.com - 2017-03-13 09:40 +0100
    Re: [PATCH] perf sort: Segmentation fault of basic block cycles sort  dimension Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-03-13 15:50 +0100

#1598940 — [PATCH] perf sort: Segmentation fault of basic block cycles sort dimension

Fromchangbin.du@intel.com
Date2017-03-13 09:40 +0100
Subject[PATCH] perf sort: Segmentation fault of basic block cycles sort dimension
Message-ID<tktGi-6dB-9@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1599471 — Re: [PATCH] perf sort: Segmentation fault of basic block cycles sort dimension

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2017-03-13 15:50 +0100
SubjectRe: [PATCH] perf sort: Segmentation fault of basic block cycles sort dimension
Message-ID<tkzsl-1TD-3@gated-at.bofh.it>
In reply to#1598940
Em Mon, Mar 13, 2017 at 04:31:48PM +0800, changbin.du@intel.com escreveu:
> 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

Thanks, applied.

- Arnaldo
 
> 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web