This patch looks good for glibc, once the previous two regex patches are
done. I installed it into Gnulib by applying the attached, so that
regex_internal.h can stay in lock-step between Gnulib and glibc.
>From 87ed1f9c4bc4ae9e98e1293465a5b3a929b9c3f9 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Fri, 8 Jan 2021 17:17:32 -0800
Subject: [PATCH] regex: stop using alloca
* lib/regex_internal.h: Do not include <alloca.h> or define
__libc_use_alloca or alloca. Patch written by Adhemerval Zanella:
https://sourceware.org/pipermail/libc-alpha/2021-January/121374.html
* modules/regex (Depends-on): Remove alloca-opt.
---
ChangeLog | 6 ++++++
lib/regex_internal.h | 19 -------------------
modules/regex | 1 -
3 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 708a266b0..a2787f59a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2021-01-08 Paul Eggert <[email protected]>
+ regex: stop using alloca
+ * lib/regex_internal.h: Do not include <alloca.h> or define
+ __libc_use_alloca or alloca. Patch written by Adhemerval Zanella:
+ https://sourceware.org/pipermail/libc-alpha/2021-January/121374.html
+ * modules/regex (Depends-on): Remove alloca-opt.
+
regexec: remove alloca usage in build_trtable
Prompted by this different change proposed by Adhemerval Zanella:
https://sourceware.org/pipermail/libc-alpha/2021-January/121373.html
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 5d4d5fe2b..b4f91d9ec 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -445,25 +445,6 @@ typedef struct re_dfa_t re_dfa_t;
#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
-#if defined _LIBC || HAVE_ALLOCA
-# include <alloca.h>
-#endif
-
-#ifndef _LIBC
-# if HAVE_ALLOCA
-/* The OS usually guarantees only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- allocate anything larger than 4096 bytes. Also care for the possibility
- of a few compiler-allocated temporary stack slots. */
-# define __libc_use_alloca(n) ((n) < 4032)
-# else
-/* alloca is implemented with malloc, so just use malloc. */
-# define __libc_use_alloca(n) 0
-# undef alloca
-# define alloca(n) malloc (n)
-# endif
-#endif
-
#ifdef _LIBC
# define MALLOC_0_IS_NONNULL 1
#elif !defined MALLOC_0_IS_NONNULL
diff --git a/modules/regex b/modules/regex
index 39297dfe3..20cbe375a 100644
--- a/modules/regex
+++ b/modules/regex
@@ -16,7 +16,6 @@ Depends-on:
c99
extensions
ssize_t
-alloca-opt [test $ac_use_included_regex = yes]
btowc [test $ac_use_included_regex = yes]
builtin-expect [test $ac_use_included_regex = yes]
dynarray [test $ac_use_included_regex = yes]
--
2.27.0