From 741a7aef585b07f3510dc5566b390c6124640e65 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 15 Jun 2015 10:51:37 -0700 Subject: [PATCH] QtTest: Increase the size of the alternate stack The default (8kB) isn't enough for modern Linux on x86-64. I can't exactly account for it, as the size of the xsave area is 0x340 bytes, plus the regular area it's still less than ~1.5 kB. But empirically we can see that 8kB causes a SIGSEGV when a signal is delivered, while 16 kB works. Since we're increasing the size, let's make sure it ends up in a separate page from the rest of the .bss data. Change-Id: I5d1e6f7607404caa96e4ffff13e84c87c33723c7 Reviewed-by: Jason McDonald --- src/testlib/qtestcase.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 453288ee829..c96b72bef76 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2453,7 +2453,12 @@ FatalSignalHandler::FatalSignalHandler() #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]; +# if defined(Q_CC_GNU) && defined(Q_OF_ELF) + // Put the alternate stack in the .lbss (large BSS) section so that it doesn't + // interfere with normal .bss symbols + __attribute__((section(".lbss.altstack"), aligned(4096))) +# endif + static char alternate_stack[16 * 1024]; stack_t stack; stack.ss_flags = 0; stack.ss_size = sizeof alternate_stack;