linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Sandipan Das <sandipan@linux.ibm.com>,
	Jiri Olsa <jolsa@redhat.com>,
	"Naveen N . Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 03/19] perf report powerpc: Fix crash if callchain is empty
Date: Mon, 25 Jun 2018 14:40:29 -0300	[thread overview]
Message-ID: <20180625174045.25765-4-acme@kernel.org> (raw)
In-Reply-To: <20180625174045.25765-1-acme@kernel.org>

From: Sandipan Das <sandipan@linux.ibm.com>

For some cases, the callchain provided by the kernel may be empty. So,
the callchain ip filtering code will cause a crash if we do not check
whether the struct ip_callchain pointer is NULL before accessing any
members.

This can be observed on a powerpc64le system running Fedora 27 as shown
below.

  # perf record -b -e cycles:u ls

Before:

  # perf report --branch-history

  perf: Segmentation fault
  -------- backtrace --------
  perf[0x1027615c]
  linux-vdso64.so.1(__kernel_sigtramp_rt64+0x0)[0x7fff856304d8]
  perf(arch_skip_callchain_idx+0x44)[0x10257c58]
  perf[0x1017f2e4]
  perf(thread__resolve_callchain+0x124)[0x1017ff5c]
  perf(sample__resolve_callchain+0xf0)[0x10172788]
  ...

After:

  # perf report --branch-history

  Samples: 25  of event 'cycles:u', Event count (approx.): 2306870
    Overhead  Source:Line            Symbol                   Shared Object
  +   11.60%  _init+35736            [.] _init                ls
  +    9.84%  strcoll_l.c:137        [.] __strcoll_l          libc-2.26.so
  +    9.16%  memcpy.S:175           [.] __memcpy_power7      libc-2.26.so
  +    9.01%  gconv_charset.h:54     [.] _nl_find_locale      libc-2.26.so
  +    8.87%  dl-addr.c:52           [.] _dl_addr             libc-2.26.so
  +    8.83%  _init+236              [.] _init                ls
  ...

Reported-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
Acked-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20180611104049.11048-1-sandipan@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/arch/powerpc/util/skip-callchain-idx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
index 3598b8b75d27..ef5d59a5742e 100644
--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
+++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
@@ -243,7 +243,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
 	u64 ip;
 	u64 skip_slot = -1;
 
-	if (chain->nr < 3)
+	if (!chain || chain->nr < 3)
 		return skip_slot;
 
 	ip = chain->ips[2];
-- 
2.14.3

  parent reply	other threads:[~2018-06-25 17:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25 17:40 [GIT PULL 00/19] perf/urgent fixes for 4.18 Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 01/19] perf record: Support s390 random socket_id assignment Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 02/19] perf test session topology: Fix test on s390 Arnaldo Carvalho de Melo
2018-06-25 17:40 ` Arnaldo Carvalho de Melo [this message]
2018-06-25 17:40 ` [PATCH 04/19] perf tests: Add event parsing error handling to parse events test Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 05/19] perf tests: Add valid callback for parse-events test Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 06/19] perf intel-pt: Fix packet decoding of CYC packets Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 07/19] tools headers uapi: Synchronize drm/drm.h Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 08/19] perf tools: Update x86's syscall_64.tbl, adding 'io_pgetevents' and 'rseq' Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 09/19] tools include powerpc: Update arch/powerpc/include/uapi/asm/unistd.h copy to get 'rseq' syscall Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 10/19] tools include uapi: Update if_link.h to pick IFLA_{BRPORT_ISOLATED,VXLAN_TTL_INHERIT} Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 11/19] tools include uapi: Synchronize bpf.h with the kernel Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 12/19] perf tools: Fix a clang 7.0 compilation error Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 13/19] perf alias: Remove trailing newline when reading sysfs files Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 14/19] perf alias: Rebuild alias expression string to make it comparable Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 15/19] perf stat: Remove duplicate event counting Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 16/19] perf bench: Fix numa report output code Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 17/19] perf script: Add missing output fields in a hint Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 18/19] perf script: Fix crash because of missing evsel->priv Arnaldo Carvalho de Melo
2018-06-25 17:40 ` [PATCH 19/19] perf tools: Fix crash caused by accessing feat_ops[HEADER_LAST_FEATURE] Arnaldo Carvalho de Melo
2018-06-25 20:26 ` [GIT PULL 00/19] perf/urgent fixes for 4.18 Arnaldo Carvalho de Melo
2018-06-26  6:46 ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180625174045.25765-4-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=sandipan@linux.ibm.com \
    --cc=sukadev@linux.vnet.ibm.com \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).