From 7c8b3699bfc42c0d54b7dd0855cd244f2cff388b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 15 Jun 2015 10:51:37 -0700 Subject: 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 Reviewed-by: Jason McDonald --- src/testlib/qtestcase.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/testlib/qtestcase.cpp') 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); -- cgit v1.2.3