119 lines
4.2 KiB
Diff
119 lines
4.2 KiB
Diff
|
diff --color -ru a/include/internal/catch_fatal_condition.hpp b/include/internal/catch_fatal_condition.hpp
|
||
|
--- a/include/internal/catch_fatal_condition.hpp 2018-05-14 15:15:28.000000000 +0200
|
||
|
+++ b/include/internal/catch_fatal_condition.hpp 2021-07-15 14:08:17.297322549 +0200
|
||
|
@@ -133,10 +133,11 @@
|
||
|
|
||
|
struct FatalConditionHandler {
|
||
|
|
||
|
+ static char* altStackMem;
|
||
|
+ static std::size_t altStackSize;
|
||
|
static bool isSet;
|
||
|
static struct sigaction oldSigActions [sizeof(signalDefs)/sizeof(SignalDefs)];
|
||
|
static stack_t oldSigStack;
|
||
|
- static char altStackMem[SIGSTKSZ];
|
||
|
|
||
|
static void handleSignal( int sig ) {
|
||
|
std::string name = "<unknown signal>";
|
||
|
@@ -153,10 +154,16 @@
|
||
|
}
|
||
|
|
||
|
FatalConditionHandler() {
|
||
|
+ assert(!altStackMem && "Cannot initialize POSIX signal handler when one already exists");
|
||
|
+ if (altStackSize == 0) {
|
||
|
+ altStackSize = std::max(static_cast<size_t>(SIGSTKSZ), (size_t)(32 * 1024));
|
||
|
+ }
|
||
|
+ altStackMem = new char[altStackSize]();
|
||
|
+
|
||
|
isSet = true;
|
||
|
stack_t sigStack;
|
||
|
sigStack.ss_sp = altStackMem;
|
||
|
- sigStack.ss_size = SIGSTKSZ;
|
||
|
+ sigStack.ss_size = altStackSize;
|
||
|
sigStack.ss_flags = 0;
|
||
|
sigaltstack(&sigStack, &oldSigStack);
|
||
|
struct sigaction sa = { 0 };
|
||
|
@@ -171,6 +178,11 @@
|
||
|
|
||
|
~FatalConditionHandler() {
|
||
|
reset();
|
||
|
+
|
||
|
+ delete[] altStackMem;
|
||
|
+ // We signal that another instance can be constructed by zeroing
|
||
|
+ // out the pointer.
|
||
|
+ altStackMem = nullptr;
|
||
|
}
|
||
|
static void reset() {
|
||
|
if( isSet ) {
|
||
|
@@ -185,10 +197,11 @@
|
||
|
}
|
||
|
};
|
||
|
|
||
|
+ char* FatalConditionHandler::altStackMem = nullptr;
|
||
|
+ std::size_t FatalConditionHandler::altStackSize = 0;
|
||
|
bool FatalConditionHandler::isSet = false;
|
||
|
struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {};
|
||
|
stack_t FatalConditionHandler::oldSigStack = {};
|
||
|
- char FatalConditionHandler::altStackMem[SIGSTKSZ] = {};
|
||
|
|
||
|
|
||
|
} // namespace Catch
|
||
|
diff --color -ru a/single_include/catch.hpp b/single_include/catch.hpp
|
||
|
--- a/single_include/catch.hpp 2018-05-14 15:15:28.000000000 +0200
|
||
|
+++ b/single_include/catch.hpp 2021-07-15 14:21:18.755941570 +0200
|
||
|
@@ -6537,10 +6537,11 @@
|
||
|
|
||
|
struct FatalConditionHandler {
|
||
|
|
||
|
+ static char* altStackMem;
|
||
|
+ static std::size_t altStackSize;
|
||
|
static bool isSet;
|
||
|
static struct sigaction oldSigActions [sizeof(signalDefs)/sizeof(SignalDefs)];
|
||
|
static stack_t oldSigStack;
|
||
|
- static char altStackMem[SIGSTKSZ];
|
||
|
|
||
|
static void handleSignal( int sig ) {
|
||
|
std::string name = "<unknown signal>";
|
||
|
@@ -6557,10 +6558,16 @@
|
||
|
}
|
||
|
|
||
|
FatalConditionHandler() {
|
||
|
+ assert(!altStackMem && "Cannot initialize POSIX signal handler when one already exists");
|
||
|
+ if (altStackSize == 0) {
|
||
|
+ altStackSize = std::max(static_cast<size_t>(SIGSTKSZ), (size_t)(32 * 1024));
|
||
|
+ }
|
||
|
+ altStackMem = new char[altStackSize]();
|
||
|
+
|
||
|
isSet = true;
|
||
|
stack_t sigStack;
|
||
|
sigStack.ss_sp = altStackMem;
|
||
|
- sigStack.ss_size = SIGSTKSZ;
|
||
|
+ sigStack.ss_size = altStackSize;
|
||
|
sigStack.ss_flags = 0;
|
||
|
sigaltstack(&sigStack, &oldSigStack);
|
||
|
struct sigaction sa = { 0 };
|
||
|
@@ -6574,6 +6581,11 @@
|
||
|
|
||
|
~FatalConditionHandler() {
|
||
|
reset();
|
||
|
+
|
||
|
+ delete[] altStackMem;
|
||
|
+ // We signal that another instance can be constructed by zeroing
|
||
|
+ // out the pointer.
|
||
|
+ altStackMem = nullptr;
|
||
|
}
|
||
|
static void reset() {
|
||
|
if( isSet ) {
|
||
|
@@ -6588,10 +6600,11 @@
|
||
|
}
|
||
|
};
|
||
|
|
||
|
+ char* FatalConditionHandler::altStackMem = nullptr;
|
||
|
+ std::size_t FatalConditionHandler::altStackSize = 0;
|
||
|
bool FatalConditionHandler::isSet = false;
|
||
|
struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {};
|
||
|
stack_t FatalConditionHandler::oldSigStack = {};
|
||
|
- char FatalConditionHandler::altStackMem[SIGSTKSZ] = {};
|
||
|
|
||
|
} // namespace Catch
|
||
|
|