From: Francis Giraldeau <francis.giraldeau@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Francis Giraldeau <francis.giraldeau@gmail.com>
Subject: [PATCH] Prevent infinite loop if unwind fails
Date: Fri, 22 Nov 2013 16:19:16 -0500 [thread overview]
Message-ID: <1385155156-26573-1-git-send-email-francis.giraldeau@gmail.com> (raw)
Unwind may loop forever if sample is incomplete or bogus. Bound the number of
unw_step() that yield the same IP to prevent infinite loop.
Signed-off-by: Francis Giraldeau <francis.giraldeau@gmail.com>
---
tools/perf/util/unwind.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/unwind.c b/tools/perf/util/unwind.c
index 958723b..bf45b6b 100644
--- a/tools/perf/util/unwind.c
+++ b/tools/perf/util/unwind.c
@@ -520,7 +520,8 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
{
unw_addr_space_t addr_space;
unw_cursor_t c;
- int ret;
+ unw_word_t prev_ip = 0;
+ int ret, rec = 0;
addr_space = unw_create_addr_space(&accessors, 0);
if (!addr_space) {
@@ -537,6 +538,11 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
unw_get_reg(&c, UNW_REG_IP, &ip);
ret = entry(ip, ui->thread, ui->machine, cb, arg);
+ if (prev_ip != ip)
+ rec = 0;
+ if (++rec >= 100)
+ break;
+ prev_ip = ip;
}
unw_destroy_addr_space(addr_space);
--
1.8.1.2
reply other threads:[~2013-11-22 21:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1385155156-26573-1-git-send-email-francis.giraldeau@gmail.com \
--to=francis.giraldeau@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®