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


Groups > linux.kernel > #1259643 > unrolled thread

[RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with --stdio

Started byNamhyung Kim <namhyung@kernel.org>
First post2015-10-30 18:20 +0100
Last post2015-11-02 07:50 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with --stdio Namhyung Kim <namhyung@kernel.org> - 2015-10-30 18:20 +0100
    Re: [RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with  --stdio Jiri Olsa <jolsa@redhat.com> - 2015-10-31 17:20 +0100
      Re: [RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with  --stdio Namhyung Kim <namhyung@kernel.org> - 2015-11-02 07:50 +0100

#1259643 — [RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with --stdio

FromNamhyung Kim <namhyung@kernel.org>
Date2015-10-30 18:20 +0100
Subject[RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with --stdio
Message-ID<qplvk-8A-13@gated-at.bofh.it>
ipchain__fprintf_graph() should pass non-NULL callchain node when
printing remaining entries.  Otherwise it'll segfault since it tries to
access to the node to calculate the value.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/stdio/hist.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 4a7b007c2a87..2104b09d41a8 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -88,6 +88,7 @@ static size_t __callchain__fprintf_graph(FILE *fp, struct rb_root *root,
 	size_t ret = 0;
 	int i;
 	uint entries_printed = 0;
+	int cumul_count = 0;
 
 	remaining = total_samples;
 
@@ -99,6 +100,7 @@ static size_t __callchain__fprintf_graph(FILE *fp, struct rb_root *root,
 		child = rb_entry(node, struct callchain_node, rb_node);
 		cumul = callchain_cumul_hits(child);
 		remaining -= cumul;
+		cumul_count += callchain_cumul_counts(child);
 
 		/*
 		 * The depth mask manages the output of pipes that show
@@ -141,12 +143,21 @@ static size_t __callchain__fprintf_graph(FILE *fp, struct rb_root *root,
 
 	if (callchain_param.mode == CHAIN_GRAPH_REL &&
 		remaining && remaining != total_samples) {
+		struct callchain_node rem_node = {
+			.hit = remaining,
+		};
 
 		if (!rem_sq_bracket)
 			return ret;
 
+		if (callchain_param.value == CCVAL_COUNT) {
+			rem_node.count = child->parent->children_count - cumul_count;
+			if (rem_node.count <= 0)
+				return ret;
+		}
+
 		new_depth_mask &= ~(1 << (depth - 1));
-		ret += ipchain__fprintf_graph(fp, NULL, &rem_hits, depth,
+		ret += ipchain__fprintf_graph(fp, &rem_node, &rem_hits, depth,
 					      new_depth_mask, 0, total_samples,
 					      left_margin);
 	}
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1260019 — Re: [RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with --stdio

FromJiri Olsa <jolsa@redhat.com>
Date2015-10-31 17:20 +0100
SubjectRe: [RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with --stdio
Message-ID<qpH2N-50U-15@gated-at.bofh.it>
In reply to#1259643
On Sat, Oct 31, 2015 at 02:15:38AM +0900, Namhyung Kim wrote:

SNIP

>  
>  		if (!rem_sq_bracket)
>  			return ret;
>  
> +		if (callchain_param.value == CCVAL_COUNT) {
> +			rem_node.count = child->parent->children_count - cumul_count;
> +			if (rem_node.count <= 0)
> +				return ret;
> +		}
> +
>  		new_depth_mask &= ~(1 << (depth - 1));
> -		ret += ipchain__fprintf_graph(fp, NULL, &rem_hits, depth,
> +		ret += ipchain__fprintf_graph(fp, &rem_node, &rem_hits, depth,
>  					      new_depth_mask, 0, total_samples,
>  					      left_margin);

this looks like being introduced within your patchset in patch:
  perf callchain: Abstract callchain print function

shouldn't it get fixed in there?

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1260414 — Re: [RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with --stdio

FromNamhyung Kim <namhyung@kernel.org>
Date2015-11-02 07:50 +0100
SubjectRe: [RFC/PATCH 5/5] perf report: Fix segfault on -g fractral with --stdio
Message-ID<qqh6h-20g-1@gated-at.bofh.it>
In reply to#1260019
Hi Jiri,

On Sat, Oct 31, 2015 at 12:09:46PM +0100, Jiri Olsa wrote:
> On Sat, Oct 31, 2015 at 02:15:38AM +0900, Namhyung Kim wrote:
> 
> SNIP
> 
> >  
> >  		if (!rem_sq_bracket)
> >  			return ret;
> >  
> > +		if (callchain_param.value == CCVAL_COUNT) {
> > +			rem_node.count = child->parent->children_count - cumul_count;
> > +			if (rem_node.count <= 0)
> > +				return ret;
> > +		}
> > +
> >  		new_depth_mask &= ~(1 << (depth - 1));
> > -		ret += ipchain__fprintf_graph(fp, NULL, &rem_hits, depth,
> > +		ret += ipchain__fprintf_graph(fp, &rem_node, &rem_hits, depth,
> >  					      new_depth_mask, 0, total_samples,
> >  					      left_margin);
> 
> this looks like being introduced within your patchset in patch:
>   perf callchain: Abstract callchain print function
> 
> shouldn't it get fixed in there?

Right. I'll move it to the commit

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web