From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#56108: 29.0.50; ASAN use-after-free in re_match_2_internal Date: Thu, 23 Jun 2022 17:29:13 -0400 Message-ID: References: <83mte7kv7c.fsf@gnu.org> <32e548cc-ffd3-4669-ad9a-317c130b0c93@Spark> <83a6a4kec0.fsf@gnu.org> <6e56407a-b564-4aa9-b74c-78883727ef09@Spark> <831qvgkc8d.fsf@gnu.org> <83sfnwisbb.fsf@gnu.org> <3146c990-63d9-4aa5-ab78-7bae2b7d6cd5@Spark> <835ykrg93i.fsf@gnu.org> <831qvfg876.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37425"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: gerd.moellmann@gmail.com, 56108@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 23 23:30:28 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4UPC-0009cS-Tp for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jun 2022 23:30:27 +0200 Original-Received: from localhost ([::1]:48306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4UPB-0007qy-JE for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jun 2022 17:30:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4UOq-0007p4-9j for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2022 17:30:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4UOp-0005vn-WC for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2022 17:30:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o4UOo-0007jR-Pl for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2022 17:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Jun 2022 21:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56108 X-GNU-PR-Package: emacs Original-Received: via spool by 56108-submit@debbugs.gnu.org id=B56108.165601976529655 (code B ref 56108); Thu, 23 Jun 2022 21:30:02 +0000 Original-Received: (at 56108) by debbugs.gnu.org; 23 Jun 2022 21:29:25 +0000 Original-Received: from localhost ([127.0.0.1]:40160 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4UOC-0007iF-No for submit@debbugs.gnu.org; Thu, 23 Jun 2022 17:29:24 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:63617) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4UOB-0007i3-Dk for 56108@debbugs.gnu.org; Thu, 23 Jun 2022 17:29:23 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BB7AA441D22; Thu, 23 Jun 2022 17:29:17 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 73FA3441D21; Thu, 23 Jun 2022 17:29:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1656019756; bh=wU3tbo8sbW3uxGetBJxBzM9Mg9IH8skeAmXwIJPsLd8=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=JtiW/6+n8LJ8V/XN8r4i7khB2DlAPyjFTNdNK3twdfN/a2RW/18dxJhR4vW+5soaX p9mn1Ki0ich8YZvEezLcxxepzUrizEZRzHgsdfId7HGqRcN2RoQSuHOyHSwf9T+5+0 aIYSFr8W60AduEFeEvKeUVXIiXUEoApjFqMWvwZzEdOVr0mkDqeiWARtq70NaZ4Qdj tdZtQt4TJPLD/U35BpcrXOjCY66Wt/sTycK/cR4sC4CtJlXjbCQp78BwO74Gj+NhJK UdoTxQNHcSH/Bo4dI98aBfotOKG9RX0u5xKTNzJkBb6i4MQkzkxttQUbhxT4/ysuMd X+K3MwQsli3PQ== Original-Received: from alfajor (196.214.25.93.rev.sfr.net [93.25.214.196]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 73CE01204DE; Thu, 23 Jun 2022 17:29:15 -0400 (EDT) In-Reply-To: <831qvfg876.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 23 Jun 2022 10:17:17 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:235139 Archived-At: > Stefan, do you happen to know why some of the callers of > compile_pattern don't call freeze_pattern to protect the new cache > entry? Is it just an omission or do we miss something here? 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. At least, that's my recollection. Stefan