From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754683AbcJUARQ (ORCPT ); Thu, 20 Oct 2016 20:17:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52106 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754584AbcJUARO (ORCPT ); Thu, 20 Oct 2016 20:17:14 -0400 Date: Fri, 21 Oct 2016 02:17:06 +0200 From: Jiri Olsa To: Kim Phillips Cc: Arnaldo Carvalho de Melo , Ingo Molnar , linux-kernel@vger.kernel.org, Linux Weekly News , Andi Kleen , David Ahern , Don Zickus , Jiri Olsa , Joe Mario , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH] perf c2c report: Properly check data presence in rb_tree loop Message-ID: <20161021001706.GB23970@krava> References: <1476975876-2522-1-git-send-email-acme@kernel.org> <20161020180224.23b087c217663cd262ddc873@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161020180224.23b087c217663cd262ddc873@arm.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 21 Oct 2016 00:17:14 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 20, 2016 at 06:02:24PM -0500, Kim Phillips wrote: SNIP > (gdb) bt > #0 c2c_browser__update_nr_entries (hb=, hb=) at builtin-c2c.c:2142 > #1 perf_c2c__hists_browse (hists=0x8b2d90 ) at builtin-c2c.c:2287 > #2 perf_c2c_display (session=0x205b1a0) at builtin-c2c.c:2316 > #3 perf_c2c__report (argv=, argc=) at builtin-c2c.c:2621 > #4 cmd_c2c (argc=, argv=, prefix=) at builtin-c2c.c:2748 > #5 0x000000000048df61 in run_builtin (p=p@entry=0x8be168 , argc=argc@entry=2, argv=argv@entry=0x7fffffffddb0) > at perf.c:358 > #6 0x00000000004249b6 in handle_internal_command (argv=0x7fffffffddb0, argc=2) at perf.c:420 > #7 run_argv (argv=0x7fffffffdb40, argcp=0x7fffffffdb4c) at perf.c:466 > #8 main (argc=2, argv=0x7fffffffddb0) at perf.c:610 > (gdb) > > All the above work fine when run under sudo. ugh, stupid mistake.. attached patch fixes that for me thanks, jirka --- Kim reported crash when there's no data stored. In this case the TUI code crashes in c2c_browser__update_nr_entries, because we dont check the initial rb_tree node for NULL. Adding the missing check. Reported-by: Kim Phillips Signed-off-by: Jiri Olsa --- tools/perf/builtin-c2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index dc4f0636dfa1..c6d0dda594d9 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2135,14 +2135,14 @@ static void c2c_browser__update_nr_entries(struct hist_browser *hb) u64 nr_entries = 0; struct rb_node *nd = rb_first(&hb->hists->entries); - do { + while (nd) { struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node); if (!he->filtered) nr_entries++; nd = rb_next(nd); - } while (nd); + } hb->nr_non_filtered_entries = nr_entries; } -- 2.7.4