From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: emacs-devel@gnu.org
Cc: Tassilo Horn <tsdh@gnu.org>
Subject: Re: [Emacs-diffs] emacs-25 fe27e03: Fix rx matcher overflow without limiting
Date: Mon, 14 Dec 2015 12:34:59 -0500 [thread overview]
Message-ID: <jwv37v5djg4.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <E1a8Ws5-00057V-DG@vcs.savannah.gnu.org> (Tassilo Horn's message of "Mon, 14 Dec 2015 17:25:13 +0000")
> - "\\[[^][]\\{0,2000\\}\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
> + ;;
> + ;; If you think the first shy group is a bit strange, it is like
> + ;; that in order not to overflow the regexp matcher stack in the
> + ;; presence of unbalanced brackets, i.e., a [ and then no
> + ;; closing bracket anymore. In "[^[],]*,", the "*" repetition
> + ;; will be done without any need to record state for eventual
> + ;; backtracking because the "," is mutually exclusive with the
> + ;; "[^][,]", and the regexp matcher includes a special
> + ;; optimization for that case since it's common and very
> + ;; useful). (Hint by Stefan Monnier)
> + "\\[\\(?:[^][,]*,\\)*[ \t]*\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
As mentioned in my email, this doesn't remove all risks of overflows,
since the second * still requires stashing the state onto the stack for
backtracking, but that's only "once per comma" instead of "once
per char", so in practice we can hope we won't bump into it.
Stefan
next parent reply other threads:[~2015-12-14 17:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20151214172513.19647.43539@vcs.savannah.gnu.org>
[not found] ` <E1a8Ws5-00057V-DG@vcs.savannah.gnu.org>
2015-12-14 17:34 ` Stefan Monnier [this message]
2015-12-14 17:56 ` [Emacs-diffs] emacs-25 fe27e03: Fix rx matcher overflow without limiting Tassilo Horn
2015-12-14 17:58 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv37v5djg4.fsf-monnier+emacsdiffs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=tsdh@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).