aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoshua Peraza <jperaza@chromium.org>2020-08-14 10:25:39 -0700
committerJoshua Peraza <jperaza@chromium.org>2020-08-14 17:26:39 +0000
commit087795c851d269a49baf6cd0fb886c2990729f44 (patch)
treeb973f59e426ee4ebd14835a1eb493db106e4ec60 /src
parentEscape more characters in Mac OS sym-upload-v2 debug_file strings. (diff)
downloadbreakpad-087795c851d269a49baf6cd0fb886c2990729f44.tar.xz
processor: subtract 1 from return pointers while scanning
Each stackwalker subtracts the size of an instruction from a frame's instruction pointer to determine which instruction it was executing. This should also be done for pointers examined while scanning for likely return addresses to ensure that those pointers don't point past the end of functions. Bug: b/118634446 Change-Id: I043e3f1e51a2c0a3d99ed14bf18ea64dc98add44 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2356649 Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/google_breakpad/processor/stackwalker.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/google_breakpad/processor/stackwalker.h b/src/google_breakpad/processor/stackwalker.h
index 0c458d50..daa5039a 100644
--- a/src/google_breakpad/processor/stackwalker.h
+++ b/src/google_breakpad/processor/stackwalker.h
@@ -176,8 +176,12 @@ class Stackwalker {
if (!memory_->GetMemoryAtAddress(location, &ip))
break;
- if (modules_ && modules_->GetModuleForAddress(ip) &&
- InstructionAddressSeemsValid(ip)) {
+ // The return address points to the instruction after a call. If the
+ // caller was a no return function, this might point past the end of the
+ // function. Subtract one from the instruction pointer so it points into
+ // the call instruction instead.
+ if (modules_ && modules_->GetModuleForAddress(ip - 1) &&
+ InstructionAddressSeemsValid(ip - 1)) {
*ip_found = ip;
*location_found = location;
return true;