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


Groups > linux.kernel > #1222527

[PATCH] perf tools: Fix segfault in 'perf top'

From Wang Nan <wangnan0@huawei.com>
Newsgroups linux.kernel
Subject [PATCH] perf tools: Fix segfault in 'perf top'
Date 2015-09-11 07:00 +0200
Message-ID <q7oBj-89G-1@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


'perf top' segfaults with following operation:

 # perf top -e page-faults -p 15173 # 15173 never generate page-fault

Then on the resulting empty interface, press right key:

 # ./perf top -e page-faults -p 11400
 perf: Segmentation fault
 -------- backtrace --------
 ./perf[0x535428]
 /lib64/libc.so.6(+0x3545f)[0x7f0dd360745f]
 ./perf[0x531d46]
 ./perf(perf_evlist__tui_browse_hists+0x96)[0x5340d6]
 ./perf[0x44ba2f]
 /lib64/libpthread.so.0(+0x81d0)[0x7f0dd49dc1d0]
 /lib64/libc.so.6(clone+0x6c)[0x7f0dd36b90dc]

The bug reside in perf_evsel__hists_browse() that, in the above circumstance
browser->selection can be NULL, but code after skip_annotation doesn't consider
it.

This patch fix it by checing browser->selection before fetching
browser->selection->map and browser->selection->sym.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index e4fd40f..b00fa92 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2017,7 +2017,8 @@ skip_annotation:
 					  &options[nr_options], dso);
 		nr_options += add_map_opt(browser, &actions[nr_options],
 					  &options[nr_options],
-					  browser->selection->map);
+					  browser->selection ?
+					  	browser->selection->map : NULL);
 		nr_options += add_socket_opt(browser, &actions[nr_options],
 					     &options[nr_options],
 					     socket);
@@ -2030,7 +2031,10 @@ skip_annotation:
 			nr_options += add_script_opt(browser,
 						     &actions[nr_options],
 						     &options[nr_options],
-						     NULL, browser->selection->sym);
+						     NULL,
+						     browser->selection ?
+						     	browser->selection->sym :
+							NULL);
 		}
 		nr_options += add_script_opt(browser, &actions[nr_options],
 					     &options[nr_options], NULL, NULL);
-- 
1.8.3.4

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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] perf tools: Fix segfault in 'perf top' Wang Nan <wangnan0@huawei.com> - 2015-09-11 07:00 +0200
  Re: [PATCH] perf tools: Fix segfault in 'perf top' Namhyung Kim <namhyung@kernel.org> - 2015-09-11 18:30 +0200
    Re: [PATCH] perf tools: Fix segfault in 'perf top' "Wangnan (F)" <wangnan0@huawei.com> - 2015-09-14 12:20 +0200
    [PATCH v2] perf tools: Fix segfault in 'perf top' Wang Nan <wangnan0@huawei.com> - 2015-09-14 12:30 +0200
      Re: [PATCH v2] perf tools: Fix segfault in 'perf top' Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 20:10 +0200
        Re: [PATCH v2] perf tools: Fix segfault in 'perf top' Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-09-14 20:20 +0200
      [tip:perf/core] perf top: Fix segfault pressing ->   with no hist entries tip-bot for Wang Nan <tipbot@zytor.com> - 2015-09-16 09:30 +0200

csiph-web