From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#40661: Crash in regex search during redisplay Date: Fri, 17 Apr 2020 11:28:49 -0400 Message-ID: References: <83ftd3e92z.fsf@gnu.org> <83d087e6gj.fsf@gnu.org> <421071D0-6D75-4442-AC4B-D091B573B49C@dancol.org> <838siucq7b.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="48949"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Richard Copley , 40661@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 17 17:29:21 2020 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 1jPSvh-000Cct-Ng for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Apr 2020 17:29:21 +0200 Original-Received: from localhost ([::1]:48518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPSvg-00005a-Qj for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Apr 2020 11:29:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52442) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPSvP-0008Ia-H3 for bug-gnu-emacs@gnu.org; Fri, 17 Apr 2020 11:29:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jPSvO-0004dD-Cy for bug-gnu-emacs@gnu.org; Fri, 17 Apr 2020 11:29:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jPSvO-0004d8-9m for bug-gnu-emacs@gnu.org; Fri, 17 Apr 2020 11:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jPSvO-0000uP-3w for bug-gnu-emacs@gnu.org; Fri, 17 Apr 2020 11:29: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: Fri, 17 Apr 2020 15:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40661 X-GNU-PR-Package: emacs Original-Received: via spool by 40661-submit@debbugs.gnu.org id=B40661.15871373393480 (code B ref 40661); Fri, 17 Apr 2020 15:29:02 +0000 Original-Received: (at 40661) by debbugs.gnu.org; 17 Apr 2020 15:28:59 +0000 Original-Received: from localhost ([127.0.0.1]:41500 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPSvL-0000u4-Gb for submit@debbugs.gnu.org; Fri, 17 Apr 2020 11:28:59 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:58339) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPSvK-0000to-8U for 40661@debbugs.gnu.org; Fri, 17 Apr 2020 11:28:58 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id E9DDA100958; Fri, 17 Apr 2020 11:28:52 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 33E2810031F; Fri, 17 Apr 2020 11:28:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1587137331; bh=WvZsg5INsd5KSCo+31NbotMs3s26BhB1pTuiXImF5Sg=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=BCKBOq/369VHzoAG4O4KSJ+TfQUhsLX0W9jN+j3DUoVx83tdkYil9vuh8i3v9A0YE 9/qZy1U7Py/dZXNftYwOg5i2CPpSTfNG9qvTey/yu3V42GvTTlBgaU7Zttaio88iGD nAm+KeMTb3mAp/H07KcGfiS0B3I1fNeAV8owtC+L5uw64ovilM8Jkxk3TKXk3EjSxl PqebyxNES7RDtOjJxsMC2SvAcok0HViX3S+jHIrYzBVG/5GGcuSrHydpQklda6LS2Y T0eNuLETpQZ2WKoO0yLBFb6VuuHqgEjyNy//wdq1BisEv0axG36GUt84g3mzBf/R40 AyoMQQx+C/1AA== Original-Received: from alfajor (unknown [104.247.241.114]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DF262120873; Fri, 17 Apr 2020 11:28:50 -0400 (EDT) In-Reply-To: <838siucq7b.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 17 Apr 2020 14:22:00 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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:178521 Archived-At: > I finally succeeded to build a sophisticated enough trap to catch the > culprit. It's GC allright. Which is not surprising: the commit > pointed out by Richard changed re_match_2_internal to call > UPDATE_SYNTAX_TABLE_FORWARD, which calls Lisp, and thus can trigger > GC. As seen from the backtrace, GC then calls compact_buffer, which > calls enlarge_buffer_text (to shrink buffer text), and on MS-Windows > -- and this is the w32-specific part -- we return some memory to the > OS and relocate buffer text. > > Obviously, we cannot allow GC to run while regex routines do their > work, because they are passed C pointers to buffer text. The question > is, where to disable GC? We could do it inside > update_syntax_table_forward, but UPDATE_SYNTAX_TABLE_FORWARD is called > from many places that evidently have no problems with GC. So my > suggestion would be to disable GC inside re_match_2_internal instead. > > Comments? Looks fine to me. I think a better fix is to move the execution of compact_buffer: there's no reason it has to be done during GC, we just need to do it "every once in a while" and the GC was a convenient point for that. But we could avoid several such problems if we were to run such background tasks elsewhere. It could still be linked to GC, e.g. we could start a timer during the GC so its run at the next opportunity. Stefan