perf hists browser: Fix segfault when all entries be filtered
PATCH 1/1 perf hists browser: Fix segfault when all entries be filtered
When all perf report entries be filtered, the result of hists__filter_entries() can be NULL, check the result before processing.
Miss this checking will cause segmentation fault like this:
$ perf report
(filter all entries and left nothing, then zoom in/out)
perf: Segmentation fault
-------- backtrace -------- ../bin/perf[0x4d1858] ../lib64/libc.so.6(+0x3545f)[0x7fe72fc1145f] ../bin/perf[0x4cd9f5]
../bin/perf[0x4ce176]
../bin/perf[0x4d0506]
../bin/perf[0x41a94f]
../bin/perf[0x408cf2]
../bin/perf[0x408455] ../lib64/libc.so.6(__libc_start_main+0xf4)[0x7fe72fbfdbd4] ../bin/perf[0x408584]
--- tools/perf/ui/browsers/hists.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/ui/browsers/hists.c +3 -0
@@ -992,6 +992,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser,* and stop when we printed enough lines to fill the screen. */ do_offset: +if (!nd) +return ; +if (offset >0 ) { do { h = rb_entry(nd, struct hist_entry, rb_node);
Signature · 1 line
2.2.0.33.gc18b867
ping..
Quoted 40 lines · He Kuang
When all perf report entries be filtered, the result of
hists__filter_entries()can be NULL, check the result before processing.Miss this checking will cause segmentation fault like this:
$ perf report(filter all entries and left nothing, then zoom in/out)
perf: Segmentation fault
-------- backtrace -------- ../bin/perf[0x4d1858] ../lib64/libc.so.6(+0x3545f)[0x7fe72fc1145f] ../bin/perf[0x4cd9f5]
../bin/perf[0x4ce176]
../bin/perf[0x4d0506]
../bin/perf[0x41a94f]
../bin/perf[0x408cf2]
../bin/perf[0x408455] ../lib64/libc.so.6(__libc_start_main+0xf4)[0x7fe72fbfdbd4] ../bin/perf[0x408584]Signed-off-by He Kuang <[email protected]>--- tools/perf/ui/browsers/hists.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/ui/browsers/hists.c +3
-0@@ -992,6 +992,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser,* and stop when we printed enough lines to fill the screen. */ do_offset: +if (!nd) +return ; +if (offset >0 ) { do { h = rb_entry(nd, struct hist_entry, rb_node);
Namhyung Kim
maintainerHi,
Quoted 4 lines · He Kuang
ping..
Quoted 2 lines · He Kuang
When all perf report entries be filtered, the result of
hists__filter_entries()can be NULL, check the result before processing.
In that case, browser->nr_entries should be zero IMHO. But it seems there's a place missing to update the number.
Thanks,
Namhyung
Quoted 45 lines
Quoted 29 lines
Miss this checking will cause segmentation fault like this:
$ perf report(filter all entries and left nothing, then zoom in/out)
perf: Segmentation fault
-------- backtrace -------- ../bin/perf[0x4d1858] ../lib64/libc.so.6(+0x3545f)[0x7fe72fc1145f] ../bin/perf[0x4cd9f5]
../bin/perf[0x4ce176]
../bin/perf[0x4d0506]
../bin/perf[0x41a94f]
../bin/perf[0x408cf2]
../bin/perf[0x408455] ../lib64/libc.so.6(__libc_start_main+0xf4)[0x7fe72fbfdbd4] ../bin/perf[0x408584]Signed-off-by He Kuang <[email protected]>--- tools/perf/ui/browsers/hists.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/ui/browsers/hists.c +0
-0tools/perf/ui/browsers/hists.c static void ui_browser__hists_seek(struct ui_browser *browser, · line 1000
Quoted 9 lines
tools/perf/ui/browsers/hists.c +3
-0@@ -992,6 +992,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser,* and stop when we printed enough lines to fill the screen. */ do_offset: +if (!nd) +return ; +if (offset >0 ) { do { h = rb_entry(nd, struct hist_entry, rb_node);--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/