All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf hists browser: Fix segfault when showing callchain
@ 2014-12-24  6:04 Namhyung Kim
  2015-01-08 15:08 ` Arnaldo Carvalho de Melo
  2015-01-09 12:31 ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  0 siblings, 2 replies; 3+ messages in thread
From: Namhyung Kim @ 2014-12-24  6:04 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, Adrian Hunter,
	Stephane Eranian, Andi Kleen, Frederic Weisbecker

When perf report on TUI shows callchain it checks first node has
siblings to determine whether it needs to print percentage value.  But
it missed a case that first node is NULL.  So sometimes it segfaults
like below:

  $ perf top -g
  perf: Segmentation fault
  -------- backtrace --------
  perf[0x4fcefb]
  /usr/lib/libc.so.6(+0x33b20)[0x7f2a35839b20]
  perf(rb_next+0x8)[0x47d3d8]
  perf[0x4f6058]
  perf[0x4f833b]
  perf[0x4f8610]
  perf[0x4f209e]
  perf(ui_browser__run+0x3a)[0x4f2e6a]
  perf[0x4f94ee]
  perf(perf_evlist__tui_browse_hists+0x94)[0x4fbbf4]
  perf[0x444d10]
  /usr/lib/libpthread.so.0(+0x7314)[0x7f2a37070314]
  /usr/lib/libc.so.6(clone+0x6d)[0x7f2a358ee5bd]

  $ addr2line -e `which perf` 0x4f6058
  /home/namhyung/project/linux/tools/perf/ui/browsers/hists.c:553

I don't know why the backtrace didn't print some symbols..

Fixes: 4087d11cd945 ("perf hists browser: Print overhead percent value for first-level callchain")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index e6bb04b5b09b..788506eef567 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -550,7 +550,7 @@ static int hist_browser__show_callchain(struct hist_browser *browser,
 	bool need_percent;
 
 	node = rb_first(root);
-	need_percent = !!rb_next(node);
+	need_percent = node && rb_next(node);
 
 	while (node) {
 		struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf hists browser: Fix segfault when showing callchain
  2014-12-24  6:04 [PATCH] perf hists browser: Fix segfault when showing callchain Namhyung Kim
@ 2015-01-08 15:08 ` Arnaldo Carvalho de Melo
  2015-01-09 12:31 ` [tip:perf/urgent] " tip-bot for Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-01-08 15:08 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, Adrian Hunter,
	Stephane Eranian, Andi Kleen, Frederic Weisbecker

Em Wed, Dec 24, 2014 at 03:04:36PM +0900, Namhyung Kim escreveu:
> When perf report on TUI shows callchain it checks first node has
> siblings to determine whether it needs to print percentage value.  But
> it missed a case that first node is NULL.  So sometimes it segfaults
> like below:

Thanks, applied.
 
>   $ perf top -g
>   perf: Segmentation fault
>   -------- backtrace --------
>   perf[0x4fcefb]
>   /usr/lib/libc.so.6(+0x33b20)[0x7f2a35839b20]
>   perf(rb_next+0x8)[0x47d3d8]
>   perf[0x4f6058]
>   perf[0x4f833b]
>   perf[0x4f8610]
>   perf[0x4f209e]
>   perf(ui_browser__run+0x3a)[0x4f2e6a]
>   perf[0x4f94ee]
>   perf(perf_evlist__tui_browse_hists+0x94)[0x4fbbf4]
>   perf[0x444d10]
>   /usr/lib/libpthread.so.0(+0x7314)[0x7f2a37070314]
>   /usr/lib/libc.so.6(clone+0x6d)[0x7f2a358ee5bd]
> 
>   $ addr2line -e `which perf` 0x4f6058
>   /home/namhyung/project/linux/tools/perf/ui/browsers/hists.c:553
> 
> I don't know why the backtrace didn't print some symbols..
> 
> Fixes: 4087d11cd945 ("perf hists browser: Print overhead percent value for first-level callchain")
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/ui/browsers/hists.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index e6bb04b5b09b..788506eef567 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -550,7 +550,7 @@ static int hist_browser__show_callchain(struct hist_browser *browser,
>  	bool need_percent;
>  
>  	node = rb_first(root);
> -	need_percent = !!rb_next(node);
> +	need_percent = node && rb_next(node);
>  
>  	while (node) {
>  		struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node);
> -- 
> 2.1.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/urgent] perf hists browser: Fix segfault when showing callchain
  2014-12-24  6:04 [PATCH] perf hists browser: Fix segfault when showing callchain Namhyung Kim
  2015-01-08 15:08 ` Arnaldo Carvalho de Melo
@ 2015-01-09 12:31 ` tip-bot for Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Namhyung Kim @ 2015-01-09 12:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: eranian, namhyung, mingo, fweisbec, andi, adrian.hunter,
	linux-kernel, acme, hpa, jolsa, tglx, a.p.zijlstra

Commit-ID:  c09e31cc128cf1aec3a6cd47203508fbf0082873
Gitweb:     http://git.kernel.org/tip/c09e31cc128cf1aec3a6cd47203508fbf0082873
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Wed, 24 Dec 2014 15:04:36 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 8 Jan 2015 11:59:16 -0300

perf hists browser: Fix segfault when showing callchain

When perf report on TUI shows callchain it checks first node has
siblings to determine whether it needs to print percentage value.

But it missed a case that first node is NULL.  So sometimes it segfaults
like below:

  $ perf top -g
  perf: Segmentation fault
  -------- backtrace --------
  perf[0x4fcefb]
  /usr/lib/libc.so.6(+0x33b20)[0x7f2a35839b20]
  perf(rb_next+0x8)[0x47d3d8]
  perf[0x4f6058]
  perf[0x4f833b]
  perf[0x4f8610]
  perf[0x4f209e]
  perf(ui_browser__run+0x3a)[0x4f2e6a]
  perf[0x4f94ee]
  perf(perf_evlist__tui_browse_hists+0x94)[0x4fbbf4]
  perf[0x444d10]
  /usr/lib/libpthread.so.0(+0x7314)[0x7f2a37070314]
  /usr/lib/libc.so.6(clone+0x6d)[0x7f2a358ee5bd]

  $ addr2line -e `which perf` 0x4f6058
  /home/namhyung/project/linux/tools/perf/ui/browsers/hists.c:553

I don't know why the backtrace didn't print some symbols..

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Fixes: 4087d11cd945 ("perf hists browser: Print overhead percent value for first-level callchain")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1419401076-21700-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index e6bb04b..788506e 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -550,7 +550,7 @@ static int hist_browser__show_callchain(struct hist_browser *browser,
 	bool need_percent;
 
 	node = rb_first(root);
-	need_percent = !!rb_next(node);
+	need_percent = node && rb_next(node);
 
 	while (node) {
 		struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-09 12:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-24  6:04 [PATCH] perf hists browser: Fix segfault when showing callchain Namhyung Kim
2015-01-08 15:08 ` Arnaldo Carvalho de Melo
2015-01-09 12:31 ` [tip:perf/urgent] " tip-bot for Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.