From bb4fe2a3ad12ca01da545f2decc1733927877e6d Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Thu, 31 May 2012 14:43:27 +0900 Subject: [PATCH] --- yaml --- r: 310589 b: refs/heads/master c: 114067b69e7b2c691faace0e33db2f04096f668d h: refs/heads/master i: 310587: 225261c8ce4b34aaa962c9891726b25b2d535df4 v: v3 --- [refs] | 2 +- trunk/include/linux/perf_event.h | 4 ++-- trunk/tools/perf/util/session.c | 14 +++++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index d6a4c2802ff6..dc8364453aa3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 472606458f3e1ced5fe3cc5f04e90a6b5a4732cf +refs/heads/master: 114067b69e7b2c691faace0e33db2f04096f668d diff --git a/trunk/include/linux/perf_event.h b/trunk/include/linux/perf_event.h index f32578634d9d..1817d4015e5f 100644 --- a/trunk/include/linux/perf_event.h +++ b/trunk/include/linux/perf_event.h @@ -555,6 +555,8 @@ enum perf_event_type { PERF_RECORD_MAX, /* non-ABI */ }; +#define PERF_MAX_STACK_DEPTH 255 + enum perf_callchain_context { PERF_CONTEXT_HV = (__u64)-32, PERF_CONTEXT_KERNEL = (__u64)-128, @@ -609,8 +611,6 @@ struct perf_guest_info_callbacks { #include #include -#define PERF_MAX_STACK_DEPTH 255 - struct perf_callchain_entry { __u64 nr; __u64 ip[PERF_MAX_STACK_DEPTH]; diff --git a/trunk/tools/perf/util/session.c b/trunk/tools/perf/util/session.c index 3b6f8e460a31..04d1e33f4592 100644 --- a/trunk/tools/perf/util/session.c +++ b/trunk/tools/perf/util/session.c @@ -300,6 +300,11 @@ int machine__resolve_callchain(struct machine *self, callchain_cursor_reset(&callchain_cursor); + if (chain->nr > PERF_MAX_STACK_DEPTH) { + pr_warning("corrupted callchain. skipping...\n"); + return 0; + } + for (i = 0; i < chain->nr; i++) { u64 ip; struct addr_location al; @@ -318,7 +323,14 @@ int machine__resolve_callchain(struct machine *self, case PERF_CONTEXT_USER: cpumode = PERF_RECORD_MISC_USER; break; default: - break; + pr_debug("invalid callchain context: " + "%"PRId64"\n", (s64) ip); + /* + * It seems the callchain is corrupted. + * Discard all. + */ + callchain_cursor_reset(&callchain_cursor); + return 0; } continue; }