Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | # HG changeset patch |
michael@0 | 2 | # User Julian Seward <jseward@acm.org> |
michael@0 | 3 | # Date 1366643454 -7200 |
michael@0 | 4 | # Mon Apr 22 17:10:54 2013 +0200 |
michael@0 | 5 | # Node ID 3e64f12d9dab619c90bee02ed071bcda0100844e |
michael@0 | 6 | # Parent 6d06a09b3f5624dd833bd6f905bfd88e3fdec00a |
michael@0 | 7 | Bug 859745 - Install sane unwinding limit for SPS/breakpad. r=ted |
michael@0 | 8 | |
michael@0 | 9 | diff --git a/src/google_breakpad/processor/stackwalker.h b/src/google_breakpad/processor/stackwalker.h |
michael@0 | 10 | --- a/src/google_breakpad/processor/stackwalker.h |
michael@0 | 11 | +++ b/src/google_breakpad/processor/stackwalker.h |
michael@0 | 12 | @@ -83,17 +83,20 @@ class Stackwalker { |
michael@0 | 13 | // argument. If no suitable concrete subclass exists, returns NULL. |
michael@0 | 14 | static Stackwalker* StackwalkerForCPU( |
michael@0 | 15 | const SystemInfo* system_info, |
michael@0 | 16 | MinidumpContext* context, |
michael@0 | 17 | MemoryRegion* memory, |
michael@0 | 18 | const CodeModules* modules, |
michael@0 | 19 | StackFrameSymbolizer* resolver_helper); |
michael@0 | 20 | |
michael@0 | 21 | - static void set_max_frames(uint32_t max_frames) { max_frames_ = max_frames; } |
michael@0 | 22 | + static void set_max_frames(uint32_t max_frames) { |
michael@0 | 23 | + max_frames_ = max_frames; |
michael@0 | 24 | + max_frames_set_ = true; |
michael@0 | 25 | + } |
michael@0 | 26 | static uint32_t max_frames() { return max_frames_; } |
michael@0 | 27 | |
michael@0 | 28 | protected: |
michael@0 | 29 | // system_info identifies the operating system, NULL or empty if unknown. |
michael@0 | 30 | // memory identifies a MemoryRegion that provides the stack memory |
michael@0 | 31 | // for the stack to walk. modules, if non-NULL, is a CodeModules |
michael@0 | 32 | // object that is used to look up which code module each stack frame is |
michael@0 | 33 | // associated with. frame_symbolizer is a StackFrameSymbolizer object that |
michael@0 | 34 | @@ -191,14 +194,19 @@ class Stackwalker { |
michael@0 | 35 | // the end of the stack has been reached). GetCallerFrame allocates a new |
michael@0 | 36 | // StackFrame (or StackFrame subclass), ownership of which is taken by |
michael@0 | 37 | // the caller. |
michael@0 | 38 | virtual StackFrame* GetCallerFrame(const CallStack* stack) = 0; |
michael@0 | 39 | |
michael@0 | 40 | // The maximum number of frames Stackwalker will walk through. |
michael@0 | 41 | // This defaults to 1024 to prevent infinite loops. |
michael@0 | 42 | static uint32_t max_frames_; |
michael@0 | 43 | + |
michael@0 | 44 | + // Keep track of whether max_frames_ has been set by the user, since |
michael@0 | 45 | + // it affects whether or not an error message is printed in the case |
michael@0 | 46 | + // where an unwind got stopped by the limit. |
michael@0 | 47 | + static bool max_frames_set_; |
michael@0 | 48 | }; |
michael@0 | 49 | |
michael@0 | 50 | } // namespace google_breakpad |
michael@0 | 51 | |
michael@0 | 52 | |
michael@0 | 53 | #endif // GOOGLE_BREAKPAD_PROCESSOR_STACKWALKER_H__ |
michael@0 | 54 | diff --git a/src/processor/stackwalker.cc b/src/processor/stackwalker.cc |
michael@0 | 55 | --- a/src/processor/stackwalker.cc |
michael@0 | 56 | +++ b/src/processor/stackwalker.cc |
michael@0 | 57 | @@ -52,16 +52,17 @@ |
michael@0 | 58 | #include "processor/stackwalker_x86.h" |
michael@0 | 59 | #include "processor/stackwalker_amd64.h" |
michael@0 | 60 | #include "processor/stackwalker_arm.h" |
michael@0 | 61 | |
michael@0 | 62 | namespace google_breakpad { |
michael@0 | 63 | |
michael@0 | 64 | const int Stackwalker::kRASearchWords = 30; |
michael@0 | 65 | uint32_t Stackwalker::max_frames_ = 1024; |
michael@0 | 66 | +bool Stackwalker::max_frames_set_ = false; |
michael@0 | 67 | |
michael@0 | 68 | Stackwalker::Stackwalker(const SystemInfo* system_info, |
michael@0 | 69 | MemoryRegion* memory, |
michael@0 | 70 | const CodeModules* modules, |
michael@0 | 71 | StackFrameSymbolizer* frame_symbolizer) |
michael@0 | 72 | : system_info_(system_info), |
michael@0 | 73 | memory_(memory), |
michael@0 | 74 | modules_(modules), |
michael@0 | 75 | @@ -120,17 +121,20 @@ bool Stackwalker::Walk(CallStack* stack, |
michael@0 | 76 | modules_without_symbols->push_back(frame->module); |
michael@0 | 77 | } |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | // Add the frame to the call stack. Relinquish the ownership claim |
michael@0 | 81 | // over the frame, because the stack now owns it. |
michael@0 | 82 | stack->frames_.push_back(frame.release()); |
michael@0 | 83 | if (stack->frames_.size() > max_frames_) { |
michael@0 | 84 | - BPLOG(ERROR) << "The stack is over " << max_frames_ << " frames."; |
michael@0 | 85 | + // Only emit an error message in the case where the limit that we |
michael@0 | 86 | + // reached is the default limit, not set by the user. |
michael@0 | 87 | + if (!max_frames_set_) |
michael@0 | 88 | + BPLOG(ERROR) << "The stack is over " << max_frames_ << " frames."; |
michael@0 | 89 | break; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | // Get the next frame and take ownership. |
michael@0 | 93 | frame.reset(GetCallerFrame(stack)); |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | return true; |