From c12eb1117c8d91773ea0c138eb220addec1448d0 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 5 Jun 2014 21:40:43 +0000 Subject: [PATCH] unwind: fix a bug in range updating of binary search * unwind.c (print_stacktrace): Fix another off-by-one error in binary search. --- unwind.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unwind.c b/unwind.c index d23fef66..0ebec928 100644 --- a/unwind.c +++ b/unwind.c @@ -291,7 +291,7 @@ stacktrace_walk(struct tcb *tcp, unw_word_t function_off_set; int stack_depth = 0, ret_val; /* these are used for the binary search through the mmap_chace */ - unsigned int lower, upper, mid; + int lower, upper, mid; size_t symbol_name_size = 40; char * symbol_name; struct mmap_cache_t* cur_mmap_cache; @@ -318,7 +318,7 @@ stacktrace_walk(struct tcb *tcp, } lower = 0; - upper = tcp->mmap_cache_size - 1; + upper = (int) tcp->mmap_cache_size - 1; while (lower <= upper) { /* find the mmap_cache and print the stack frame */ @@ -371,7 +371,7 @@ stacktrace_walk(struct tcb *tcp, goto ret; } else if (ip < cur_mmap_cache->start_addr) - upper = mid; + upper = mid - 1; else lower = mid + 1; -- 2.40.0