mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.3327: no check for sysconf() failing
Problem: No check for sysconf() failing. Solution: If sysconf() fails use SIGSTKSZ for the signal stack size. (Zdenek Dohnal, closes #8743)
This commit is contained in:
committed by
Bram Moolenaar
parent
6e48b84c5f
commit
ba9c23e776
@@ -783,16 +783,36 @@ mch_stackcheck(char *p)
|
|||||||
* completely full.
|
* completely full.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined SIGSTKSZ && !defined(HAVE_SYSCONF_SIGSTKSZ)
|
|
||||||
# define SIGSTKSZ 8000 // just a guess of how much stack is needed...
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# ifdef HAVE_SIGALTSTACK
|
# ifdef HAVE_SIGALTSTACK
|
||||||
static stack_t sigstk; // for sigaltstack()
|
static stack_t sigstk; // for sigaltstack()
|
||||||
# else
|
# else
|
||||||
static struct sigstack sigstk; // for sigstack()
|
static struct sigstack sigstk; // for sigstack()
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a size of signal stack.
|
||||||
|
* Preference (if available): sysconf > SIGSTKSZ > guessed size
|
||||||
|
*/
|
||||||
|
static long int get_signal_stack_size()
|
||||||
|
{
|
||||||
|
# ifdef HAVE_SYSCONF_SIGSTKSZ
|
||||||
|
long int size = -1;
|
||||||
|
|
||||||
|
// return size only if sysconf doesn't return an error
|
||||||
|
if ((size = sysconf(_SC_SIGSTKSZ)) > -1)
|
||||||
|
return size;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef SIGSTKSZ
|
||||||
|
// if sysconf() isn't available or gives error, return SIGSTKSZ
|
||||||
|
// if defined
|
||||||
|
return SIGSTKSZ;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
// otherwise guess the size
|
||||||
|
return 8000;
|
||||||
|
}
|
||||||
|
|
||||||
static char *signal_stack;
|
static char *signal_stack;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -806,21 +826,13 @@ init_signal_stack(void)
|
|||||||
# else
|
# else
|
||||||
sigstk.ss_sp = signal_stack;
|
sigstk.ss_sp = signal_stack;
|
||||||
# endif
|
# endif
|
||||||
# ifdef HAVE_SYSCONF_SIGSTKSZ
|
sigstk.ss_size = get_signal_stack_size();
|
||||||
sigstk.ss_size = sysconf(_SC_SIGSTKSZ);
|
|
||||||
# else
|
|
||||||
sigstk.ss_size = SIGSTKSZ;
|
|
||||||
# endif
|
|
||||||
sigstk.ss_flags = 0;
|
sigstk.ss_flags = 0;
|
||||||
(void)sigaltstack(&sigstk, NULL);
|
(void)sigaltstack(&sigstk, NULL);
|
||||||
# else
|
# else
|
||||||
sigstk.ss_sp = signal_stack;
|
sigstk.ss_sp = signal_stack;
|
||||||
if (stack_grows_downwards)
|
if (stack_grows_downwards)
|
||||||
# ifdef HAVE_SYSCONF_SIGSTKSZ
|
sigstk.ss_sp += get_signal_stack_size() - 1;
|
||||||
sigstk.ss_sp += sysconf(_SC_SIGSTKSZ) - 1;
|
|
||||||
# else
|
|
||||||
sigstk.ss_sp += SIGSTKSZ - 1;
|
|
||||||
# endif
|
|
||||||
sigstk.ss_onstack = 0;
|
sigstk.ss_onstack = 0;
|
||||||
(void)sigstack(&sigstk, NULL);
|
(void)sigstack(&sigstk, NULL);
|
||||||
# endif
|
# endif
|
||||||
@@ -3278,11 +3290,7 @@ mch_early_init(void)
|
|||||||
* Ignore any errors.
|
* Ignore any errors.
|
||||||
*/
|
*/
|
||||||
#if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
|
#if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
|
||||||
# ifdef HAVE_SYSCONF_SIGSTKSZ
|
signal_stack = alloc(get_signal_stack_size());
|
||||||
signal_stack = alloc(sysconf(_SC_SIGSTKSZ));
|
|
||||||
# else
|
|
||||||
signal_stack = alloc(SIGSTKSZ);
|
|
||||||
# endif
|
|
||||||
init_signal_stack();
|
init_signal_stack();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3327,
|
||||||
/**/
|
/**/
|
||||||
3326,
|
3326,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user