From 5a224b981ee32d7cf59aaa9e2c101af65a275edc Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Mon, 20 Feb 2023 19:14:12 +0100 Subject: [PATCH] Dynamically allocate the alternate signal stack. This patch is a backport of https://github.com/ocaml/ocaml/pull/10266. --- asmrun/signals_asm.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/asmrun/signals_asm.c b/asmrun/signals_asm.c index 3895d75..7e2abe8 100644 --- a/asmrun/signals_asm.c +++ b/asmrun/signals_asm.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 d>
path: root/gnu/packages/c.scm
AgeCommit message (Expand)Author
2023-12-02gnu: Add pcg-c....* gnu/packages/c.scm (pcg-c): New variable. Signed-off-by: Ludovic Courtès <ludo@gnu.org> David Elsing
2023-11-15gnu: mimalloc: Update to 2.1.2....* gnu/packages/c.scm (mimalloc): Update to 2.1.2. Change-Id: I20ff922250f57beabb427d72e82579e0059fd4f2 Efraim Flashner
2023-11-15gnu: mimalloc: Fix building on powerpc-linux....* gnu/packages/c.scm (mimalloc)[arguments]: When building for powerpc-linux add a configure-flag to use libatomic. Change-Id: I41062686186640bc4c685a0ee5de1e613040dfb9 Efraim Flashner
2023-09-08gnu: Add nsync....* gnu/packages/c.scm (nsync): New variable. Signed-off-by: Ricardo Wurmus <rekado@elephly.net> Andy Tai
2023-06-21gnu: Add tomlc99....* gnu/packages/c.scm (tomlc99): New variable. Signed-off-by: Jean-Pierre De Jesus DIAZ <jean@foundationdevices.com> Signed-off-by: Ludovic Courtès <ludo@gnu.org> Jean-Pierre De Jesus DIAZ
2023-06-18gnu: renameat2: Move to (gnu packages linux)....Being Linux-specific, that's probably a better home. * gnu/packages/c.scm (renameat2): Move to... * gnu/packages/linux.scm (renameat2): ... here. Maxim Cournoyer
2023-06-18gnu: Add renameat2....* gnu/packages/c.scm (renameat2): New variable. Maxim Cournoyer
2023-05-14gnu: Add c-rrb....* gnu/packages/c.scm (c-rrb): New variable. Liliana Marie Prikler
2023-05-11gnu: Add ISPC....* gnu/packages/c.scm (ispc): New variable. Signed-off-by: 宋文武 <iyzsong@member.fsf.org> zamfofex