From 04dcd6e79c3d59c41429d8494ad0657922a1849fc5d23bb429366bc699239363 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Tue, 20 Jul 2021 08:43:37 +0000 Subject: [PATCH] Accepting request 907135 from home:Andreas_Schwab:glibc:rebuild - gnulib-c-stack.patch: c-stack: stop using SIGSTKSZ OBS-URL: https://build.opensuse.org/request/show/907135 OBS-URL: https://build.opensuse.org/package/show/Base:System/diffutils?expand=0&rev=62 --- diffutils.changes | 5 ++ diffutils.spec | 5 +- gnulib-c-stack.patch | 122 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 gnulib-c-stack.patch diff --git a/diffutils.changes b/diffutils.changes index 8749377..9f7a2ad 100644 --- a/diffutils.changes +++ b/diffutils.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Jul 19 12:50:49 UTC 2021 - Andreas Schwab + +- gnulib-c-stack.patch: c-stack: stop using SIGSTKSZ + ------------------------------------------------------------------- Mon Aug 31 10:02:12 UTC 2020 - Bernhard Voelker diff --git a/diffutils.spec b/diffutils.spec index 84ab8cc..f410f7e 100644 --- a/diffutils.spec +++ b/diffutils.spec @@ -1,7 +1,7 @@ # # spec file for package diffutils # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -27,8 +27,9 @@ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz Source1: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig Source2: %{name}.keyring Patch0: gnulib-test-avoid-FP-perror-strerror.patch +Patch1: gnulib-c-stack.patch Requires(pre): %{install_info_prereq} -Requires(preun): %{install_info_prereq} +Requires(preun):%{install_info_prereq} Provides: diff = %{version} Obsoletes: diff < %{version} diff --git a/gnulib-c-stack.patch b/gnulib-c-stack.patch new file mode 100644 index 0000000..f4a2a97 --- /dev/null +++ b/gnulib-c-stack.patch @@ -0,0 +1,122 @@ +From f9e2b20a12a230efa30f1d479563ae07d276a94b Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Wed, 30 Sep 2020 13:50:36 -0700 +Subject: [PATCH] c-stack: stop using SIGSTKSZ +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It’s been proposed to stop making SIGSTKSZ an integer constant: +https://sourceware.org/pipermail/libc-alpha/2020-September/118028.html +Also, using SIGSTKSZ in #if did not conform to current POSIX. +Also, avoiding SIGSTKSZ makes the code simpler and easier to grok. +* lib/c-stack.c (SIGSTKSZ): Remove. +(alternate_signal_stack): Now a 64 KiB array, for simplicity. +All uses changed. +--- + ChangeLog | 9 +++++++++ + lib/c-stack.c | 42 ++++++++++++++++++------------------------ + lib/c-stack.h | 2 +- + 3 files changed, 28 insertions(+), 25 deletions(-) + +Index: diffutils-3.7/lib/c-stack.c +=================================================================== +--- diffutils-3.7.orig/lib/c-stack.c ++++ diffutils-3.7/lib/c-stack.c +@@ -50,15 +50,6 @@ + #if ! HAVE_STACK_T && ! defined stack_t + typedef struct sigaltstack stack_t; + #endif +-#ifndef SIGSTKSZ +-# define SIGSTKSZ 16384 +-#elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384 +-/* libsigsegv 2.6 through 2.8 have a bug where some architectures use +- more than the Linux default of an 8k alternate stack when deciding +- if a fault was caused by stack overflow. */ +-# undef SIGSTKSZ +-# define SIGSTKSZ 16384 +-#endif + + #include + #include +@@ -89,6 +80,16 @@ typedef struct sigaltstack stack_t; + # endif + #endif + ++/* Storage for the alternate signal stack. ++ 64 KiB is not too large for Gnulib-using apps, and is large enough ++ for all known platforms. Smaller sizes may run into trouble. ++ For example, libsigsegv 2.6 through 2.8 have a bug where some ++ architectures use more than the Linux default of an 8 KiB alternate ++ stack when deciding if a fault was caused by stack overflow. */ ++static max_align_t alternate_signal_stack[(64 * 1024 ++ + sizeof (max_align_t) - 1) ++ / sizeof (max_align_t)]; ++ + /* The user-specified action to take when a SEGV-related program error + or stack overflow occurs. */ + static void (* volatile segv_action) (int); +@@ -133,19 +134,6 @@ die (int signo) + #if (HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK \ + && HAVE_STACK_OVERFLOW_HANDLING) || HAVE_LIBSIGSEGV + +-/* Storage for the alternate signal stack. */ +-static union +-{ +- char buffer[SIGSTKSZ]; +- +- /* These other members are for proper alignment. There's no +- standard way to guarantee stack alignment, but this seems enough +- in practice. */ +- long double ld; +- long l; +- void *p; +-} alternate_signal_stack; +- + static void + null_action (int signo __attribute__ ((unused))) + { +@@ -210,8 +198,8 @@ c_stack_action (void (*action) (int)) + + /* Always install the overflow handler. */ + if (stackoverflow_install_handler (overflow_handler, +- alternate_signal_stack.buffer, +- sizeof alternate_signal_stack.buffer)) ++ alternate_signal_stack, ++ sizeof alternate_signal_stack)) + { + errno = ENOTSUP; + return -1; +@@ -284,14 +272,14 @@ c_stack_action (void (*action) (int)) + stack_t st; + struct sigaction act; + st.ss_flags = 0; ++ st.ss_sp = alternate_signal_stack; ++ st.ss_size = sizeof alternate_signal_stack; + # if SIGALTSTACK_SS_REVERSED + /* Irix mistakenly treats ss_sp as the upper bound, rather than + lower bound, of the alternate stack. */ +- st.ss_sp = alternate_signal_stack.buffer + SIGSTKSZ - sizeof (void *); +- st.ss_size = sizeof alternate_signal_stack.buffer - sizeof (void *); +-# else +- st.ss_sp = alternate_signal_stack.buffer; +- st.ss_size = sizeof alternate_signal_stack.buffer; ++ st.ss_size -= sizeof (void *); ++ char *ss_sp = st.ss_sp; ++ st.ss_sp = ss_sp + st.ss_size; + # endif + r = sigaltstack (&st, NULL); + if (r != 0) +Index: diffutils-3.7/lib/c-stack.h +=================================================================== +--- diffutils-3.7.orig/lib/c-stack.h ++++ diffutils-3.7/lib/c-stack.h +@@ -34,7 +34,7 @@ + A null ACTION acts like an action that does nothing. + + ACTION must be async-signal-safe. ACTION together with its callees +- must not require more than SIGSTKSZ bytes of stack space. Also, ++ must not require more than 64 KiB of stack space. Also, + ACTION should not call longjmp, because this implementation does + not guarantee that it is safe to return to the original stack. +