Source: catch
Followup-For: Bug #993515

Actually upsteam catch (catch2) had some criticisms of the PR#2317
patch that I referenced.

Among other things it should still use SIGSTKSZ not MINSIGSTKSZ.

The actual patch to catch2 was commit c0d0a50bd
https://github.com/catchorg/Catch2/commit/c0d0a50bdb2ae2f749443c0386c2b25379bdbf76

I adapted my dolfin patch to align with commit c0d0a50bd to use SIGSTKSZ
not MINSIGSTKSZ (and use 32 * 1024 as the backup default value).

I'm attaching the updated dolfin patch here for reference.
Index: dolfin/test/unit/cpp/catch/catch.hpp
===================================================================
--- dolfin.orig/test/unit/cpp/catch/catch.hpp   2022-02-04 17:07:26.964175029 
+0100
+++ dolfin/test/unit/cpp/catch/catch.hpp        2022-02-04 17:08:30.528792625 
+0100
@@ -6472,6 +6472,17 @@
         int id;
         const char* name;
     };
+
+// 32kb for the alternate stack seems to be sufficient. However, this value
+// is experimentally determined, 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 altStackSize = 32 * 1024;
+#else
+    static constexpr std::size_t altStackSize = 
std::max(static_cast<size_t>(SIGSTKSZ), 32 * 1024)
+#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[altStackSize];
 
         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 = altStackSize;
             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[altStackSize] = {};
 
 } // namespace Catch
 

Reply via email to