Package: aseba
Version: 1.6.99+dfsg
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu kinetic ubuntu-patch

Dear Maintainer,

SIGSTKSZ is not constant anymore so altStackMem must be allocated
dynamically: this patch implements what is done upstream.

In Ubuntu, the attached patch was applied to fix the FTBFS as can be
seen in [1].

Not related but I updated the homepage link to directly point to aseba,
it took me a few minutes to find it from the original link.

Thanks for considering the patch.

[1] 
https://launchpad.net/~alexghiti/+archive/ubuntu/riscv/+sourcepub/13492679/+listing-archive-extra

-- System Information:
Debian Release: bookworm/sid
  APT prefers jammy-updates
  APT policy: (500, 'jammy-updates'), (500, 'jammy-security'), (500, 'jammy')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.15.0-27-generic (SMP w/16 CPU threads)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru aseba-1.6.99+dfsg/debian/control aseba-1.6.99+dfsg/debian/control
--- aseba-1.6.99+dfsg/debian/control    2020-09-17 18:17:11.000000000 +0200
+++ aseba-1.6.99+dfsg/debian/control    2022-05-03 16:24:08.000000000 +0200
@@ -15,7 +15,7 @@
 Standards-Version: 4.5.0
 Vcs-Browser: https://salsa.debian.org/science-team/aseba.git
 Vcs-Git: https://salsa.debian.org/science-team/aseba.git
-Homepage: https://www.thymio.org/
+Homepage: https://github.com/aseba-community/aseba
 
 Package: aseba
 Architecture: any
diff -Nru 
aseba-1.6.99+dfsg/debian/patches/0001-third_party-catch2-Fix-non-constant-SIGSTKSZ.patch
 
aseba-1.6.99+dfsg/debian/patches/0001-third_party-catch2-Fix-non-constant-SIGSTKSZ.patch
--- 
aseba-1.6.99+dfsg/debian/patches/0001-third_party-catch2-Fix-non-constant-SIGSTKSZ.patch
    1970-01-01 01:00:00.000000000 +0100
+++ 
aseba-1.6.99+dfsg/debian/patches/0001-third_party-catch2-Fix-non-constant-SIGSTKSZ.patch
    2022-05-03 16:21:52.000000000 +0200
@@ -0,0 +1,81 @@
+From 830dbd151a5743629f3c6fb2827bb65bb6bca70d Mon Sep 17 00:00:00 2001
+From: Alexandre Ghiti <alexandre.gh...@canonical.com>
+Date: Tue, 3 May 2022 15:15:12 +0200
+Subject: [PATCH] third_party: catch2: Fix non-constant SIGSTKSZ
+
+SIGSTKSZ is not constant anymore so altStackMem must be allocated
+dynamically: this patch implements what is done upstream.
+
+Signed-off-by: Alexandre Ghiti <alexandre.gh...@canonical.com>
+---
+ third_party/catch2/include/catch2/catch.hpp | 23 ++++++++++++++++++---
+ 1 file changed, 20 insertions(+), 3 deletions(-)
+
+diff --git a/third_party/catch2/include/catch2/catch.hpp 
b/third_party/catch2/include/catch2/catch.hpp
+index 081cb41..2de9330 100644
+--- a/third_party/catch2/include/catch2/catch.hpp
++++ b/third_party/catch2/include/catch2/catch.hpp
+@@ -4731,7 +4731,8 @@ namespace Catch {
+         static bool isSet;
+         static struct sigaction oldSigActions[];
+         static stack_t oldSigStack;
+-        static char altStackMem[];
++        static char* altStackMem;
++        static std::size_t altStackSize;
+ 
+         static void handleSignal( int sig );
+ 
+@@ -7226,6 +7227,11 @@ namespace {
+     void reportFatal( char const * const message ) {
+         
Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( 
message );
+     }
++
++    //! Minimal size Catch2 needs for its own fatal error handling.
++    //! Picked empirically, so it might not be sufficient on all
++    //! platforms, and for all configurations.
++    constexpr std::size_t minStackSizeForErrors = 32 * 1024;
+ }
+ 
+ #endif // signals/SEH handling
+@@ -7318,10 +7324,16 @@ namespace Catch {
+     }
+ 
+     FatalConditionHandler::FatalConditionHandler() {
++        assert(!altStackMem && "Cannot initialize POSIX signal handler when 
one already exists");
++        if (altStackSize == 0) {
++            altStackSize = std::max(static_cast<size_t>(SIGSTKSZ), 
minStackSizeForErrors);
++        }
++        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 = { };
+@@ -7334,6 +7346,10 @@ namespace Catch {
+     }
+ 
+     FatalConditionHandler::~FatalConditionHandler() {
++        delete[] altStackMem;
++        // We signal that another instance can be constructed by zeroing
++        // out the pointer.
++        altStackMem = nullptr;
+         reset();
+     }
+ 
+@@ -7352,7 +7368,8 @@ namespace Catch {
+     bool FatalConditionHandler::isSet = false;
+     struct sigaction 
FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = 
{};
+     stack_t FatalConditionHandler::oldSigStack = {};
+-    char FatalConditionHandler::altStackMem[SIGSTKSZ] = {};
++    char* FatalConditionHandler::altStackMem = nullptr;
++    std::size_t FatalConditionHandler::altStackSize = 0;
+ 
+ } // namespace Catch
+ 
+-- 
+2.34.1
+
diff -Nru aseba-1.6.99+dfsg/debian/patches/series 
aseba-1.6.99+dfsg/debian/patches/series
--- aseba-1.6.99+dfsg/debian/patches/series     1970-01-01 01:00:00.000000000 
+0100
+++ aseba-1.6.99+dfsg/debian/patches/series     2022-05-03 16:22:39.000000000 
+0200
@@ -0,0 +1 @@
+0001-third_party-catch2-Fix-non-constant-SIGSTKSZ.patch

Reply via email to