[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Va
From: |
Eli Zaretskii |
Subject: |
bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size") |
Date: |
Tue, 15 Nov 2016 18:12:09 +0200 |
> From: npostavs@users.sourceforge.net
> Cc: 24751@debbugs.gnu.org
> Date: Mon, 14 Nov 2016 22:08:18 -0500
>
> Actually, we should avoid increasing this limit if the stack wasn't
> increased, right? Here's what I came up with, I think it doesn't cover
> Cygwin/Windows though.
>
> diff --git c/src/emacs.c i/src/emacs.c
> index b74df21..d4655c8 100644
> --- c/src/emacs.c
> +++ i/src/emacs.c
> @@ -831,8 +831,8 @@ main (int argc, char **argv)
> re_max_failures, then add 33% to cover the size of the
> smaller stacks that regex.c successively allocates and
> discards on its way to the maximum. */
> - int ratio = 20 * sizeof (char *);
> - ratio += ratio / 3;
> + int min_ratio = 20 * sizeof (char *);
> + int ratio = min_ratio + min_ratio / 3;
>
> /* Extra space to cover what we're likely to use for other reasons. */
> int extra = 200000;
> @@ -869,6 +869,7 @@ main (int argc, char **argv)
>
> /* Don't let regex.c overflow the stack. */
> re_max_failures = lim < extra ? 0 : min (lim - extra, SIZE_MAX) /
> ratio;
> + emacs_re_safe_alloca = re_max_failures * min_ratio;
> }
> #endif /* HAVE_SETRLIMIT and RLIMIT_STACK and not CYGWIN */
Right, but I have 2 comments:
. we shouldn't set re_max_failures to zero if the amount of stack is
less than 'extra', since in that case we will allocate the failure
stack off the heap;
. emacs_re_safe_alloca should have its minimum value MAX_ALLOCA, not
zero, because SAFE_ALLOCA can still be used in regex.c, even
though the failure stack will be malloc'ed.
Thanks.
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), Eli Zaretskii, 2016/11/04
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), npostavs, 2016/11/05
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), Eli Zaretskii, 2016/11/06
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), npostavs, 2016/11/13
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), Eli Zaretskii, 2016/11/13
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), npostavs, 2016/11/14
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"),
Eli Zaretskii <=
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), npostavs, 2016/11/15
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), Eli Zaretskii, 2016/11/16
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), npostavs, 2016/11/16
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), Eli Zaretskii, 2016/11/17
- bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size"), Eli Zaretskii, 2016/11/19