Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Unified Diff: base/debug/stack_trace.cc

Issue 2692123005: Fix stack walking to notice if the frame is obviously not valid. (Closed)
Patch Set: Comments from wez. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/stack_trace.cc
diff --git a/base/debug/stack_trace.cc b/base/debug/stack_trace.cc
index 94ff7d0755ab50a650ebcee9dfbe05ab287972b2..83eb415ec1e0ee631af590e69d258f66d8693e99 100644
--- a/base/debug/stack_trace.cc
+++ b/base/debug/stack_trace.cc
@@ -111,12 +111,14 @@ bool IsStackFrameValid(uintptr_t fp, uintptr_t prev_fp, uintptr_t stack_end) {
// Check alignment.
if (fp & (sizeof(uintptr_t) - 1)) return false;
+ // A PC that is too small means we've gone off the end of the stack.
+ const uintptr_t kMinimumReasonablePC = 32768;
+ if (GetStackFramePC(fp) < kMinimumReasonablePC)
+ return false;
+
if (stack_end) {
// Both fp[0] and fp[1] must be within the stack.
if (fp > stack_end - 2 * sizeof(uintptr_t)) return false;
-
- // Additional check to filter out false positives.
- if (GetStackFramePC(fp) < 32768) return false;
}
return true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698