aboutsummaryrefslogtreecommitdiff
path: root/src/google_breakpad/processor
diff options
context:
space:
mode:
authorLeonard Mosescu <mosescu@chromium.org>2017-07-11 12:26:50 -0700
committerLeonard Mosescu <mosescu@chromium.org>2017-07-12 17:53:15 +0000
commit01431c2f61aa2af1804f1e139da9bc7c4afa9e7b (patch)
treed26ce2a6e690edd61f73488ecce56bc04a53be60 /src/google_breakpad/processor
parentA couple of minor fixes (diff)
downloadbreakpad-01431c2f61aa2af1804f1e139da9bc7c4afa9e7b.tar.xz
Handle very large stack traces
The main motivation for this change is to handle very large stack traces, normally the result of infinite recursion. This part is actually fairly simple, relaxing a few self-imposed limits on how many frames we can unwind and the max size for stack memory. Relaxing these limits requires stricter and more consistent checks for stack unwinding. There are a number of unwinding invariants that apply to all the platforms: 1. stack pointer (and frame pointer) must be within the stack memory (frame pointer, if preset, must point to the right frame too) 2. unwinding must monotonically increase SP (except for the first frame unwind, this must be a strict increase) 3. Instruction pointer (return address) must point to a valid location 4. stack pointer (and frame pointer) must be appropriately aligned This change is focused on 2), which is enough to guarantee that the unwinding doesn't get stuck in an infinite loop. 1) is implicitly validated part of accessing the stack memory (explicit checks might be nice though). 4) is ABI specific and while it may be valuable in catching suspicious frames is not in the scope of this change. 3) is also an interesting check but thanks to just-in-time compilation it's more complex than just calling StackWalker::InstructionAddressSeemsValid() and we don't want to drop parts of the callstack due to an overly conservative check. Bug: chromium:735989 Change-Id: I9aaba77c7fd028942d77c87d51b5e6f94e136ddd Reviewed-on: https://chromium-review.googlesource.com/563771 Reviewed-by: Mark Mentovai <mark@chromium.org> Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
Diffstat (limited to 'src/google_breakpad/processor')
-rw-r--r--src/google_breakpad/processor/minidump.h3
-rw-r--r--src/google_breakpad/processor/stackwalker.h17
2 files changed, 17 insertions, 3 deletions
diff --git a/src/google_breakpad/processor/minidump.h b/src/google_breakpad/processor/minidump.h
index 2651a323..34a2a44d 100644
--- a/src/google_breakpad/processor/minidump.h
+++ b/src/google_breakpad/processor/minidump.h
@@ -257,8 +257,7 @@ class MinidumpMemoryRegion : public MinidumpObject,
bool hexdump_;
unsigned int hexdump_width_;
- // The largest memory region that will be read from a minidump. The
- // default is 1MB.
+ // The largest memory region that will be read from a minidump.
static uint32_t max_bytes_;
// Base address and size of the memory region, and its position in the
diff --git a/src/google_breakpad/processor/stackwalker.h b/src/google_breakpad/processor/stackwalker.h
index 4378f75b..0c458d50 100644
--- a/src/google_breakpad/processor/stackwalker.h
+++ b/src/google_breakpad/processor/stackwalker.h
@@ -126,7 +126,15 @@ class Stackwalker {
// * This address is within a loaded module for which we have symbols,
// and falls inside a function in that module.
// Returns false otherwise.
- bool InstructionAddressSeemsValid(uint64_t address);
+ bool InstructionAddressSeemsValid(uint64_t address) const;
+
+ // Checks whether we should stop the stack trace.
+ // (either we reached the end-of-stack or we detected a
+ // broken callstack invariant)
+ bool TerminateWalk(uint64_t caller_ip,
+ uint64_t caller_sp,
+ uint64_t callee_sp,
+ bool first_unwind) const;
// The default number of words to search through on the stack
// for a return address.
@@ -217,6 +225,13 @@ class Stackwalker {
// the caller. |stack_scan_allowed| controls whether stack scanning is
// an allowable frame-recovery method, since it is desirable to be able to
// disable stack scanning in performance-critical use cases.
+ //
+ // CONSIDER: a way to differentiate between:
+ // - full stack traces
+ // - explicitly truncated traces (max_frames_)
+ // - stopping after max scanned frames
+ // - failed stack walk (breaking one of the stack walk invariants)
+ //
virtual StackFrame* GetCallerFrame(const CallStack* stack,
bool stack_scan_allowed) = 0;