From: "Mattias Engdegård" <mattiase@acm.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: schwab@suse.de, rhymer123@gmail.com, npostavs@gmail.com,
22149@debbugs.gnu.org
Subject: bug#22149: 24.4; gdb stack overflow in regexp matcher
Date: Fri, 13 Mar 2020 21:11:05 +0100 [thread overview]
Message-ID: <30E3666D-A55F-45F1-9357-AA27E4C62D65@acm.org> (raw)
In-Reply-To: <83y2s46o46.fsf@gnu.org>
13 mars 2020 kl. 20.39 skrev Eli Zaretskii <eliz@gnu.org>:
> I don't understand what that does to fix the problem, and don't really
> see why it would be urgent to fix in Emacs 27. Can you explain?
It's not urgent, but it is a bug that gdb-mi crashes with a regexp stack overflow for certain strings.
What the patch does is replacing the regexp fragment
(* (or (not (any ?\" ?\\))
(seq ?\\ nonl)))
with
(* (or (seq ?\\ nonl)
(not (any ?\" ?\\))))
Ie, try the least likely branch first (backslash-escaped char) in the inner loop, so that the successful branch is last and won't grow the regexp stack.
The effect is readily seen in an even simpler example:
(string-match "^\\(?:a\\|b\\)*c" (make-string 160000 ?a))
crashes, but
(string-match "^\\(?:b\\|a\\)*c" (make-string 160000 ?a))
works (ie, fails to match).
It was suggested for Emacs 27 since it's a known bug with a simple solution. Then again, it's not a regression from a recent release.
next prev parent reply other threads:[~2020-03-13 20:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-12 6:16 bug#22149: 24.4; gdb stack overflow in regexp matcher Cheng-An Yang
2015-12-12 10:13 ` Andreas Schwab
2016-07-01 3:16 ` npostavs
2020-03-13 18:58 ` Mattias Engdegård
2020-03-13 19:39 ` Eli Zaretskii
2020-03-13 20:11 ` Mattias Engdegård [this message]
2020-03-14 7:58 ` Eli Zaretskii
2020-03-14 9:04 ` Mattias Engdegård
2020-03-14 10:14 ` Eli Zaretskii
2020-03-14 10:43 ` Mattias Engdegård
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30E3666D-A55F-45F1-9357-AA27E4C62D65@acm.org \
--to=mattiase@acm.org \
--cc=22149@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=npostavs@gmail.com \
--cc=rhymer123@gmail.com \
--cc=schwab@suse.de \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.