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#58042: 29.0.50; ASAN use-after-free in re_match_2_internal Date: Mon, 08 May 2023 10:01:47 -0400 Message-ID: References: <83edvnv965.fsf@gnu.org> <83pmf6u76i.fsf@gnu.org> <83mtaau43p.fsf@gnu.org> <83ilkytyif.fsf@gnu.org> <877d1ewnx0.fsf@yahoo.com> 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="26159"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Gerd =?UTF-8?Q?M=C3=B6llmann?= , Eli Zaretskii , 58042@debbugs.gnu.org, Alan Third To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 08 16:09:19 2023 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 1pw1YE-0006bK-3r for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 May 2023 16:09:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pw1Y1-00043Y-TZ; Mon, 08 May 2023 10:09:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pw1Xy-00042u-V9 for bug-gnu-emacs@gnu.org; Mon, 08 May 2023 10:09:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pw1Xy-000058-Ng for bug-gnu-emacs@gnu.org; Mon, 08 May 2023 10:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pw1Xy-0006lb-Ib for bug-gnu-emacs@gnu.org; Mon, 08 May 2023 10:09: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: Mon, 08 May 2023 14:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58042 X-GNU-PR-Package: emacs Original-Received: via spool by 58042-submit@debbugs.gnu.org id=B58042.168355493125969 (code B ref 58042); Mon, 08 May 2023 14:09:02 +0000 Original-Received: (at 58042) by debbugs.gnu.org; 8 May 2023 14:08:51 +0000 Original-Received: from localhost ([127.0.0.1]:41249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pw1Xm-0006km-Lf for submit@debbugs.gnu.org; Mon, 08 May 2023 10:08:50 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:24880) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pw1Xj-0006kR-Mv for 58042@debbugs.gnu.org; Mon, 08 May 2023 10:08:48 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 68820442B87; Mon, 8 May 2023 10:08:42 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3B91C4423D9; Mon, 8 May 2023 10:08:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1683554921; bh=S2Hn2G1/liCG4wiEnMFt7jfL5Gi/p3Na8fuAJc6GouU=; h=Resent-To:Resent-From:Resent-Date:From:To:Cc:Subject:In-Reply-To: References:Date:From; b=EmdgueWr3YrLwX3kTfmhMoanzhDRCc8dCaOI+rGzqxSdwXg66Npi2K6L5nEiq4oEZ rNHu7fgId2/Jbxna8leQk1CYIF/uMVhICtzcBj8I/T5BgVPP2M1B3XbcWMGCfqhHOc 3sSU7Nzy0zKMQt3tJ6f9zQoh/KN6EJBGbOCauOuDT/4RujVDf6qm4WItgpj877sOIt P6XJAIg5yJovJBgtZ/6QC1DTvIkm6zohJIH85fbQ+7VqRTwsM/w7nzDyTJgWF4V1rf PjW/A2+HesWxcT359Q/Crh+v4yL1j3VVKfcPLqAizBM49mld3QpYU5aEVUSFsjEEpr B1FNS1/RfNDDQ== Original-Received: from pastel (unknown [45.72.217.176]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1F85F1204E8; Mon, 8 May 2023 10:08:41 -0400 (EDT) Resent-Message-ID: Resent-To: 58042@debbugs.gnu.org Resent-From: Stefan Monnier Resent-Date: Mon, 08 May 2023 10:08:40 -0400 Original-Received: from mail01.iro.umontreal.ca by mail01.iro.umontreal.ca with LMTP id eHZNGc8AWWR0GAAASs+2LQ (envelope-from ) for ; Mon, 08 May 2023 10:01:51 -0400 Original-Received: from mailscanner.iro.umontreal.ca (pmg1.iro.umontreal.ca [172.31.2.40]) by mail01.iro.umontreal.ca (Postfix) with ESMTPS id 3520D1401A0 for ; Mon, 8 May 2023 10:01:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1683554511; bh=S2Hn2G1/liCG4wiEnMFt7jfL5Gi/p3Na8fuAJc6GouU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=azrJaQ4979d+yul7V/iURvMVt+jKLgJV9oWVY5M320iLYfT+DJ9PkiOwcq84+4dmS G5KmKl1MPTvQlO6+H1LM7ZctPP1LNM+JkSPxhvtqmkf1utpc2zUMh7m/k8OHRjtHk7 lED2acx/ziEaosyBoTGUL3xS1yXAPiCkurcx+ZE+qhI5HlK6+sniK37WNRP0PHiR/Z dZqwq7HpV1He0jYSJaUoK/tpfQCBfEkloWmvWofShJ567Fs1HMbHU7bQf20F+ToCy0 jIciGLg+vaXyw50z82MYZytKEjXV4XgilfzEtt5MUIH9tE+sSdmXAjEThCmeMNghC2 gB1M4hAaYhHXA== Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 13BC0100193; Mon, 8 May 2023 10:01:51 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6AD281001A4; Mon, 8 May 2023 10:01:49 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1683554509; bh=S2Hn2G1/liCG4wiEnMFt7jfL5Gi/p3Na8fuAJc6GouU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=anB65GzMvJ+xkTlcftVUNNEv59EeS0oBCBNupP7y3yHBlVu3hAGF/S/boxd24NVof t250w0ylZiYy72zXEcxZpu2VvdfecN0vO9+F6AYftSl8BcDvYf/JcuKZMs0KRKARxo ZHnGl7pbfTK2yRv15QkqrieW/ISbCkM3WnR0ixFTXISxy+0xCymr1t4zfv7iWGXNfh XRuZxWWJOBvogzIlJo/yhtN5I2wwX6iPM0Zht69yj2Vo87OirYLsJC3vwj1ntpD7aq pW11TMbl2+qaCouI0rnZDn90XKatikdNPCyUNbzLLl8hOUt8yxVw19meljjVR9f2ri afFx/alFhpatw== Original-Received: from pastel (unknown [45.72.217.176]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E1E3C12024D; Mon, 8 May 2023 10:01:48 -0400 (EDT) In-Reply-To: <877d1ewnx0.fsf@yahoo.com> (Po Lu's message of "Wed, 05 Oct 2022 18:43:55 +0800") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:261326 Archived-At: >>> Isn't the -[EmacsView layoutSublayersOfLayer:] the problem? AFAICT from >>> a web search, this is an event handler method that is also called from >>> by the framework? >>> >>> In the olden days, it was a serious error to call into Lisp from an >>> event handler. All bets were off when that happened, not only related >>> to GC. I believe that hasn't changed much. > > Today, event handling code calls Lisp all the time (through safe_call > etc.) That happens in handle_one_xevent, ns_select, et cetera. Really? > It shouldn't affect GC at all because input is blocked for the entire > duration of each GC, except for when finalizers are run after unmarked > objects are sweeped. The problem was not if it's run from within the GC, the problem was what this code does when *it* runs the GC (or other state-changing functions). [ And indeed, the fix Gerd installed was to prevent GC while running pending_signals. But I suspect this is not sufficient because there are other forms of global state that can get messed up. ] In bug#62732 we have a related problem when code run from `maybe_quit` (an atimer in that case) from the regexp engine, and that atimer itself performs a regexp-operation, which messes up the outer regexp engine invocation because the regexp engine is still not re-entrant (in that bug, the problem is the `gl_state` global variable). Stefan