Source: catch
Version: 1.12.1-1.1
Followup-For: Bug #993515
Control: tags -1 patch

Upstream prepared a patch for catch2, PR#2317
https://github.com/catchorg/Catch2/pull/2317

dolfin uses a vendored copy of the merged catch.hpp.  I prepared a
patch for it (attached), which could be adapted for the catch package.
Index: dolfin/test/unit/cpp/catch/catch.hpp
===================================================================
--- dolfin.orig/test/unit/cpp/catch/catch.hpp   2022-02-04 16:06:38.000000000 
+0100
+++ dolfin/test/unit/cpp/catch/catch.hpp        2022-02-04 16:26:46.752782223 
+0100
@@ -6472,6 +6472,17 @@
         int id;
         const char* name;
     };
+
+// 32kb for the alternate stack seems to be sufficient. However, this value
+    // is experimentally determines, so that's not guaranteed.
+#if defined(_SC_SIGSTKSZ_SOURCE) || defined(_GNU_SOURCE)
+    // on glibc > 2.33 this is no longer constant, see
+    // 
https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;h=85e84fe53699fe9e392edffa993612ce08b2954a;hb=HEAD
+    static constexpr std::size_t sigStackSize = 32768;
+#else
+    static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : 
MINSIGSTKSZ;
+#endif
+
     extern SignalDefs signalDefs[];
     SignalDefs signalDefs[] = {
             { SIGINT,  "SIGINT - Terminal interrupt signal" },
@@ -6487,7 +6498,7 @@
         static bool isSet;
         static struct sigaction oldSigActions 
[sizeof(signalDefs)/sizeof(SignalDefs)];
         static stack_t oldSigStack;
-        static char altStackMem[SIGSTKSZ];
+        static char altStackMem[sigStackSize];
 
         static void handleSignal( int sig ) {
             std::string name = "<unknown signal>";
@@ -6507,7 +6518,7 @@
             isSet = true;
             stack_t sigStack;
             sigStack.ss_sp = altStackMem;
-            sigStack.ss_size = SIGSTKSZ;
+            sigStack.ss_size = sigStackSize;
             sigStack.ss_flags = 0;
             sigaltstack(&sigStack, &oldSigStack);
             struct sigaction sa = { 0 };
@@ -6538,7 +6549,7 @@
     bool FatalConditionHandler::isSet = false;
     struct sigaction 
FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = 
{};
     stack_t FatalConditionHandler::oldSigStack = {};
-    char FatalConditionHandler::altStackMem[SIGSTKSZ] = {};
+    char FatalConditionHandler::altStackMem[sigStackSize] = {};
 
 } // namespace Catch
 

Reply via email to