Skip to content

Commit 0e62a67

Browse files
committed
patch 8.2.2550: signal stack size is wrong with latest glibc 2.34
Problem: Signal stack size is wrong with latest glibc 2.34. Solution: Use sysconf(_SC_SIGSTKSZ) if available. (Zdenek Dohnal, closes #7895)
1 parent 1bd3cb2 commit 0e62a67

5 files changed

Lines changed: 51 additions & 1 deletion

File tree

src/auto/configure

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13943,6 +13943,30 @@ $as_echo "not usable" >&6; }
1394313943
fi
1394413944
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1394513945

13946+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _SC_SIGSTKSZ via sysconf()" >&5
13947+
$as_echo_n "checking for _SC_SIGSTKSZ via sysconf()... " >&6; }
13948+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13949+
/* end confdefs.h. */
13950+
#include <unistd.h>
13951+
int
13952+
main ()
13953+
{
13954+
(void)sysconf(_SC_SIGSTKSZ);
13955+
13956+
;
13957+
return 0;
13958+
}
13959+
_ACEOF
13960+
if ac_fn_c_try_compile "$LINENO"; then :
13961+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
13962+
$as_echo "yes" >&6; }; $as_echo "#define HAVE_SYSCONF_SIGSTKSZ 1" >>confdefs.h
13963+
13964+
else
13965+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not usable" >&5
13966+
$as_echo "not usable" >&6; }
13967+
fi
13968+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13969+
1394613970
# The cast to long int works around a bug in the HP C Compiler
1394713971
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
1394813972
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.

src/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,6 @@
496496

497497
/* Define to inline symbol or empty */
498498
#undef inline
499+
500+
/* Define if _SC_SIGSTKSZ is available via sysconf() */
501+
#undef HAVE_SYSCONF_SIGSTKSZ

src/configure.ac

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,6 +4105,15 @@ AC_TRY_COMPILE(
41054105
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
41064106
AC_MSG_RESULT(not usable))
41074107

4108+
dnl check if we have _SC_SIGSTKSZ via sysconf()
4109+
AC_MSG_CHECKING(for _SC_SIGSTKSZ via sysconf())
4110+
AC_TRY_COMPILE(
4111+
[#include <unistd.h>],
4112+
[ (void)sysconf(_SC_SIGSTKSZ);
4113+
],
4114+
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF_SIGSTKSZ),
4115+
AC_MSG_RESULT(not usable))
4116+
41084117
AC_CHECK_SIZEOF([int])
41094118
AC_CHECK_SIZEOF([long])
41104119
AC_CHECK_SIZEOF([time_t])

src/os_unix.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ mch_stackcheck(char *p)
783783
* completely full.
784784
*/
785785

786-
#ifndef SIGSTKSZ
786+
#if !defined SIGSTKSZ && !defined(HAVE_SYSCONF_SIGSTKSZ)
787787
# define SIGSTKSZ 8000 // just a guess of how much stack is needed...
788788
#endif
789789

@@ -806,13 +806,21 @@ init_signal_stack(void)
806806
# else
807807
sigstk.ss_sp = signal_stack;
808808
# endif
809+
# ifdef HAVE_SYSCONF_SIGSTKSZ
810+
sigstk.ss_size = sysconf(_SC_SIGSTKSZ);
811+
# else
809812
sigstk.ss_size = SIGSTKSZ;
813+
# endif
810814
sigstk.ss_flags = 0;
811815
(void)sigaltstack(&sigstk, NULL);
812816
# else
813817
sigstk.ss_sp = signal_stack;
814818
if (stack_grows_downwards)
819+
# ifdef HAVE_SYSCONF_SIGSTKSZ
820+
sigstk.ss_sp += sysconf(_SC_SIGSTKSZ) - 1;
821+
# else
815822
sigstk.ss_sp += SIGSTKSZ - 1;
823+
# endif
816824
sigstk.ss_onstack = 0;
817825
(void)sigstack(&sigstk, NULL);
818826
# endif
@@ -3261,7 +3269,11 @@ mch_early_init(void)
32613269
* Ignore any errors.
32623270
*/
32633271
#if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
3272+
# ifdef HAVE_SYSCONF_SIGSTKSZ
3273+
signal_stack = alloc(sysconf(_SC_SIGSTKSZ));
3274+
# else
32643275
signal_stack = alloc(SIGSTKSZ);
3276+
# endif
32653277
init_signal_stack();
32663278
#endif
32673279
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2550,
753755
/**/
754756
2549,
755757
/**/

0 commit comments

Comments
 (0)