guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch core-updates updated: gnu: ocaml-4.09: Fix signal handling with n


From: guix-commits
Subject: branch core-updates updated: gnu: ocaml-4.09: Fix signal handling with newer glibc.
Date: Sun, 19 Feb 2023 04:13:41 -0500

This is an automated email from the git hooks/post-receive script.

roptat pushed a commit to branch core-updates
in repository guix.

The following commit(s) were added to refs/heads/core-updates by this push:
     new 15bce0144b gnu: ocaml-4.09: Fix signal handling with newer glibc.
15bce0144b is described below

commit 15bce0144bb61a156b975c2d97d3edc4bcc3e68c
Author: Julien Lepiller <julien@lepiller.eu>
AuthorDate: Sun Feb 19 10:06:36 2023 +0100

    gnu: ocaml-4.09: Fix signal handling with newer glibc.
    
    * gnu/packages/patches/ocaml-4.09-dynamically-allocate-signal-stack.patch:
    New file.
    * gnu/local.mk (dist_patch_DATA): Add it.
    * gnu/packages/ocaml.scm (ocaml-4.09): Use it.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/ocaml.scm                             |  4 +-
 ...ml-4.09-dynamically-allocate-signal-stack.patch | 52 ++++++++++++++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 5bd564afff..c52bcb3ecc 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1580,6 +1580,7 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/ocaml-dose3-dont-make-printconf.patch   \
   %D%/packages/patches/ocaml-dose3-Install-mli-cmx-etc.patch   \
   %D%/packages/patches/ocaml-multiple-definitions.patch                \
+  %D%/packages/patches/ocaml-4.09-dynamically-allocate-signal-stack.patch      
\
   %D%/packages/patches/ocaml-4.09-multiple-definitions.patch   \
   %D%/packages/patches/omake-fix-non-determinism.patch \
   %D%/packages/patches/oneko-remove-nonfree-characters.patch   \
diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 3458c87818..1487ed9337 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -316,7 +316,9 @@ functional, imperative and object-oriented styles of 
programming.")
                     "http://caml.inria.fr/pub/distrib/ocaml-";
                     (version-major+minor version)
                     "/ocaml-" version ".tar.xz"))
-              (patches (search-patches 
"ocaml-4.09-multiple-definitions.patch"))
+              (patches (search-patches
+                         "ocaml-4.09-multiple-definitions.patch"
+                         "ocaml-4.09-dynamically-allocate-signal-stack.patch"))
               (sha256
                (base32
                 "1v3z5ar326f3hzvpfljg4xj8b9lmbrl53fn57yih1bkbx3gr3yzj"))))
diff --git 
a/gnu/packages/patches/ocaml-4.09-dynamically-allocate-signal-stack.patch 
b/gnu/packages/patches/ocaml-4.09-dynamically-allocate-signal-stack.patch
new file mode 100644
index 0000000000..2af1582976
--- /dev/null
+++ b/gnu/packages/patches/ocaml-4.09-dynamically-allocate-signal-stack.patch
@@ -0,0 +1,52 @@
+From 95f5016955e519c392c746e38e0c9460f2c1aa0c Mon Sep 17 00:00:00 2001
+From: Julien Lepiller <julien@lepiller.eu>
+Date: Sun, 19 Feb 2023 09:58:57 +0100
+Subject: [PATCH] Dynamically allocate the alternate signal stack.
+
+This patch is a backport of https://github.com/ocaml/ocaml/pull/10266.
+---
+ runtime/signals_nat.c | 19 +++++++++++--------
+ 1 file changed, 11 insertions(+), 8 deletions(-)
+
+diff --git a/runtime/signals_nat.c b/runtime/signals_nat.c
+index 29a5f49..a193fc2 100644
+--- a/runtime/signals_nat.c
++++ b/runtime/signals_nat.c
+@@ -182,7 +182,6 @@ DECLARE_SIGNAL_HANDLER(trap_handler)
+ #ifdef HAS_STACK_OVERFLOW_DETECTION
+ 
+ static char * system_stack_top;
+-static char sig_alt_stack[SIGSTKSZ];
+ 
+ #if defined(SYS_linux)
+ /* PR#4746: recent Linux kernels with support for stack randomization
+@@ -274,15 +273,19 @@ void caml_init_signals(void)
+ #ifdef HAS_STACK_OVERFLOW_DETECTION
+   {
+     stack_t stk;
+-    struct sigaction act;
+-    stk.ss_sp = sig_alt_stack;
++    stk.ss_sp = malloc(SIGSTKSZ);
+     stk.ss_size = SIGSTKSZ;
+     stk.ss_flags = 0;
+-    SET_SIGACT(act, segv_handler);
+-    act.sa_flags |= SA_ONSTACK | SA_NODEFER;
+-    sigemptyset(&act.sa_mask);
+-    system_stack_top = (char *) &act;
+-    if (sigaltstack(&stk, NULL) == 0) { sigaction(SIGSEGV, &act, NULL); }
++    if (stk.ss_sp != NULL) {
++      if (sigaltstack(&stk, NULL) != -1) {
++        struct sigaction act;
++        SET_SIGACT(act, segv_handler);
++        act.sa_flags |= SA_ONSTACK | SA_NODEFER;
++        sigemptyset(&act.sa_mask);
++        system_stack_top = (char *) &act;
++        sigaction(SIGSEGV, &act, NULL);
++      }
++    }
+   }
+ #endif
+ }
+-- 
+2.38.1
+



reply via email to

[Prev in Thread] Current Thread [Next in Thread]