blob: 6d764aa2666543ba69376273244d278001978dee [file] [log] [blame]
Andrew Geisslerf103a7f2021-05-07 16:09:40 -05001From f97e07ea807cc6d38774a3888a15091b20645ac6 Mon Sep 17 00:00:00 2001
2From: Paul Eggert <eggert@cs.ucla.edu>
3Date: Tue, 9 Mar 2021 11:22:59 -0800
4Subject: [PATCH] Port alternate signal stack to upcoming glibc 2.34
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9* src/sysdep.c (sigsegv_stack): Increase size to 64 KiB and align
10it to max_align_t. This copies from Gnulibs c-stack.c, and works
11around a portability bug in draft glibc 2.34, which no longer
12defines SIGSTKSZ when _GNU_SOURCE is defined.
13---
14 src/sysdep.c | 10 +++++++++-
15 1 file changed, 9 insertions(+), 1 deletion(-)
16
17diff --git a/src/sysdep.c b/src/sysdep.c
18index 941b4e2fa2..24d8832b2f 100644
19--- a/src/sysdep.c
20+++ b/src/sysdep.c
21@@ -1785,7 +1785,15 @@ handle_arith_signal (int sig)
22
23 /* Alternate stack used by SIGSEGV handler below. */
24
25-static unsigned char sigsegv_stack[SIGSTKSZ];
26+/* Storage for the alternate signal stack.
27+ 64 KiB is not too large for Emacs, and is large enough
28+ for all known platforms. Smaller sizes may run into trouble.
29+ For example, libsigsegv 2.6 through 2.8 have a bug where some
30+ architectures use more than the Linux default of an 8 KiB alternate
31+ stack when deciding if a fault was caused by stack overflow. */
32+static max_align_t sigsegv_stack[(64 * 1024
33+ + sizeof (max_align_t) - 1)
34+ / sizeof (max_align_t)];
35
36
37 /* Return true if SIGINFO indicates a stack overflow. */
38--
392.29.2
40