From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: gerd.moellmann@gmail.com, 56108@debbugs.gnu.org
Subject: bug#56108: 29.0.50; ASAN use-after-free in re_match_2_internal
Date: Fri, 24 Jun 2022 08:55:54 +0300 [thread overview]
Message-ID: <83tu8ad2qd.fsf@gnu.org> (raw)
In-Reply-To: <jwvedzfoz1i.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Thu, 23 Jun 2022 17:29:13 -0400)
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: gerd.moellmann@gmail.com, 56108@debbugs.gnu.org
> Date: Thu, 23 Jun 2022 17:29:13 -0400
>
> Before `freeze_pattern`, the design was that nothing could happen while
> running the regexp matcher (no GC, no execution of Lisp code).
>
> Commit 938d252d1c6c5e2027aa250c649deb024154f936 changed that so that
> searching inside a *buffer* could end up running ELisp code (and hence
> also GC). AFAIK this still can't happen when searching in strings.
> [ IIRC The need to run ELisp is so as to apply `syntax-table` text
> properties on demand via `syntax-propertize`. ]
>
> So I think freeze_pattern should be used in all cases where
> `compile_pattern` is used to search inside a buffer, but it shouldn't be
> necessary when searching within a string.
I think at least the scenario uncovered by Gerd, shown in this
backtrace-like form:
> maybe_gc
> Ffuncall
> call2
> signal_or_quit (eval.c:1741)
> quit (eval.c:1697)
> process_quit_flag (eval.c:1657)
> probably_quit (eval.c:1864)
> maybe_quit (lisp.h:3681)
> re_match_2_internal (regexp-emacs.c:4691)
could happen even when searching within strings. And in general, as I
tried to explain up-thread, relying on what cannot happen _today_ wrt
GC is not future-proof, the way Emacs development advances.
So I think we should install a change that calls freeze_pattern for
every pattern-cache entry as long as it is in use.
Gerd, would you please show the patch for that?
next prev parent reply other threads:[~2022-06-24 5:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 14:07 bug#56108: 29.0.50; ASAN use-after-free in re_match_2_internal Gerd Möllmann
2022-06-20 19:09 ` Eli Zaretskii
2022-06-22 8:13 ` Gerd Möllmann
2022-06-22 13:38 ` Eli Zaretskii
2022-06-22 14:10 ` Gerd Möllmann
2022-06-22 14:24 ` Eli Zaretskii
2022-06-22 15:11 ` Gerd Möllmann
2022-06-22 16:19 ` Eli Zaretskii
2022-06-23 5:53 ` Gerd Möllmann
2022-06-23 6:57 ` Eli Zaretskii
2022-06-23 7:17 ` Eli Zaretskii
2022-06-23 21:29 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-24 5:55 ` Eli Zaretskii [this message]
2022-06-24 6:01 ` Gerd Möllmann
2022-06-24 9:35 ` Gerd Möllmann
2022-06-24 15:40 ` Eli Zaretskii
2022-06-25 9:18 ` Eli Zaretskii
2022-06-27 13:26 ` Eli Zaretskii
2022-06-27 13:29 ` Gerd Möllmann
2022-06-23 8:24 ` Gerd Möllmann
2022-06-23 8:37 ` Eli Zaretskii
2022-06-23 8:49 ` Gerd Möllmann
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=83tu8ad2qd.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=56108@debbugs.gnu.org \
--cc=gerd.moellmann@gmail.com \
--cc=monnier@iro.umontreal.ca \
/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).