aboutsummaryrefslogtreecommitdiff
path: root/src/client/linux/handler/exception_handler.cc
diff options
context:
space:
mode:
authorted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-02-14 13:21:39 +0000
committerted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-02-14 13:21:39 +0000
commit87063908addf65d09f3659de31d2ec52316044a8 (patch)
treea997265afe3d946d3555d95a15d9924b125d44fe /src/client/linux/handler/exception_handler.cc
parent Add missing include. (diff)
downloadbreakpad-87063908addf65d09f3659de31d2ec52316044a8.tar.xz
Avoid setting an alternative stack for signals if there is already one
P=Mike Hommey <mh@glandium.org> R=ted at http://codereview.appspot.com/5573054/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@918 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/linux/handler/exception_handler.cc')
-rw-r--r--src/client/linux/handler/exception_handler.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc
index 823823d4..fff2d1c6 100644
--- a/src/client/linux/handler/exception_handler.cc
+++ b/src/client/linux/handler/exception_handler.cc
@@ -187,14 +187,18 @@ bool ExceptionHandler::InstallHandlers() {
// such a small stack.
static const unsigned kSigStackSize = 8192;
- signal_stack = malloc(kSigStackSize);
stack_t stack;
- memset(&stack, 0, sizeof(stack));
- stack.ss_sp = signal_stack;
- stack.ss_size = kSigStackSize;
-
- if (sys_sigaltstack(&stack, NULL) == -1)
- return false;
+ // Only set an alternative stack if there isn't already one, or if the current
+ // one is too small.
+ if (sys_sigaltstack(NULL, &stack) == -1 || !stack.ss_sp ||
+ stack.ss_size < kSigStackSize) {
+ memset(&stack, 0, sizeof(stack));
+ stack.ss_sp = malloc(kSigStackSize);
+ stack.ss_size = kSigStackSize;
+
+ if (sys_sigaltstack(&stack, NULL) == -1)
+ return false;
+ }
struct sigaction sa;
memset(&sa, 0, sizeof(sa));