summaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-02-25 17:17:56 +0100
committerBram Moolenaar <Bram@vim.org>2021-02-25 17:17:56 +0100
commit0e62a6742bca186624e97e2121c98ada30e009a0 (patch)
tree563c0f5cfa22a827bc37c5ef37c0d34863da9da1 /src/os_unix.c
parent1bd3cb201983859d86d644eef9e98cd3e9de7261 (diff)
downloadvim-git-0e62a6742bca186624e97e2121c98ada30e009a0.tar.gz
patch 8.2.2550: signal stack size is wrong with latest glibc 2.34v8.2.2550
Problem: Signal stack size is wrong with latest glibc 2.34. Solution: Use sysconf(_SC_SIGSTKSZ) if available. (Zdenek Dohnal, closes #7895)
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 1edc7e66b..1c8079917 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -783,7 +783,7 @@ mch_stackcheck(char *p)
* completely full.
*/
-#ifndef SIGSTKSZ
+#if !defined SIGSTKSZ && !defined(HAVE_SYSCONF_SIGSTKSZ)
# define SIGSTKSZ 8000 // just a guess of how much stack is needed...
#endif
@@ -806,13 +806,21 @@ init_signal_stack(void)
# else
sigstk.ss_sp = signal_stack;
# endif
+# ifdef HAVE_SYSCONF_SIGSTKSZ
+ sigstk.ss_size = sysconf(_SC_SIGSTKSZ);
+# else
sigstk.ss_size = SIGSTKSZ;
+# endif
sigstk.ss_flags = 0;
(void)sigaltstack(&sigstk, NULL);
# else
sigstk.ss_sp = signal_stack;
if (stack_grows_downwards)
+# ifdef HAVE_SYSCONF_SIGSTKSZ
+ sigstk.ss_sp += sysconf(_SC_SIGSTKSZ) - 1;
+# else
sigstk.ss_sp += SIGSTKSZ - 1;
+# endif
sigstk.ss_onstack = 0;
(void)sigstack(&sigstk, NULL);
# endif
@@ -3261,7 +3269,11 @@ mch_early_init(void)
* Ignore any errors.
*/
#if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
+# ifdef HAVE_SYSCONF_SIGSTKSZ
+ signal_stack = alloc(sysconf(_SC_SIGSTKSZ));
+# else
signal_stack = alloc(SIGSTKSZ);
+# endif
init_signal_stack();
#endif
}