summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-06-15 10:51:37 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-06-15 22:19:12 +0000
commit7c8b3699bfc42c0d54b7dd0855cd244f2cff388b (patch)
tree25cff428553aea21f86dd5def4d2b7872ca7e5e7
parent1d9a6d0859a7daca0385cbdfdf4c6b7caf32e6d8 (diff)
Let QtTest use an alternate stack for its signal handlers
Otherwise, the handler can't be called for a stack overflow. Change-Id: I5d1e6f7607404caa96e4ffff13e7fabd66011785 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Jason McDonald <macadder1@gmail.com>
-rw-r--r--src/testlib/qtestcase.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 9329cf48af..453288ee82 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -2439,7 +2439,7 @@ FatalSignalHandler::FatalSignalHandler()
sigemptyset(&handledSignals);
const int fatalSignals[] = {
- SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGFPE, SIGSEGV, SIGPIPE, SIGTERM, 0 };
+ SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGBUS, SIGFPE, SIGSEGV, SIGPIPE, SIGTERM, 0 };
struct sigaction act;
memset(&act, 0, sizeof(act));
@@ -2449,6 +2449,19 @@ FatalSignalHandler::FatalSignalHandler()
#if !defined(Q_OS_INTEGRITY)
act.sa_flags = SA_RESETHAND;
#endif
+
+#ifdef SA_ONSTACK
+ // Let the signal handlers use an alternate stack
+ // This is necessary if SIGSEGV is to catch a stack overflow
+ static char alternate_stack[SIGSTKSZ];
+ stack_t stack;
+ stack.ss_flags = 0;
+ stack.ss_size = sizeof alternate_stack;
+ stack.ss_sp = alternate_stack;
+ sigaltstack(&stack, 0);
+ act.sa_flags |= SA_ONSTACK;
+#endif
+
// Block all fatal signals in our signal handler so we don't try to close
// the testlog twice.
sigemptyset(&act.sa_mask);