From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#36328: 26.2; Args out of range on search-and-replace of *.cc file Date: Mon, 24 Jun 2019 07:52:18 +0000 Message-ID: <20190624075218.GA4781@ACM> References: <20190622132549.84518.qmail@mail.muc.de> <20190622205033.GA9167@ACM> <20190623122207.GA4736@ACM> <20190623193258.GB4736@ACM> <87k1dc2e5h.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="235836"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Jayden Navarro , 36328@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 24 09:53:10 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hfJmo-000zBu-BR for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Jun 2019 09:53:10 +0200 Original-Received: from localhost ([::1]:48612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfJmn-0005vC-CV for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Jun 2019 03:53:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59468) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfJmh-0005sx-Q9 for bug-gnu-emacs@gnu.org; Mon, 24 Jun 2019 03:53:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfJmg-0000rj-G1 for bug-gnu-emacs@gnu.org; Mon, 24 Jun 2019 03:53:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41942) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfJmg-0000rN-A9 for bug-gnu-emacs@gnu.org; Mon, 24 Jun 2019 03:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hfJmg-0007C7-4r for bug-gnu-emacs@gnu.org; Mon, 24 Jun 2019 03:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Jun 2019 07:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36328 X-GNU-PR-Package: emacs Original-Received: via spool by 36328-submit@debbugs.gnu.org id=B36328.156136274527614 (code B ref 36328); Mon, 24 Jun 2019 07:53:02 +0000 Original-Received: (at 36328) by debbugs.gnu.org; 24 Jun 2019 07:52:25 +0000 Original-Received: from localhost ([127.0.0.1]:55486 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfJm5-0007BK-6Q for submit@debbugs.gnu.org; Mon, 24 Jun 2019 03:52:25 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:21960 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hfJm4-0007BA-5c for 36328@debbugs.gnu.org; Mon, 24 Jun 2019 03:52:24 -0400 Original-Received: (qmail 17122 invoked by uid 3782); 24 Jun 2019 07:52:19 -0000 Original-Received: from acm.muc.de (p4FE15E6F.dip0.t-ipconnect.de [79.225.94.111]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 24 Jun 2019 09:52:18 +0200 Original-Received: (qmail 4791 invoked by uid 1000); 24 Jun 2019 07:52:18 -0000 Content-Disposition: inline In-Reply-To: <87k1dc2e5h.fsf@mail.linkov.net> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:161197 Archived-At: Hello, Juri. On Mon, Jun 24, 2019 at 00:19:22 +0300, Juri Linkov wrote: > >> Until this is officially fixed I've come up with the following workaround, > >> going off of the details you provided: > >> I created a "replace_fixed.el" file in "~/.emacs.d/lisp/" that is > >> replace.el taken from > >> https://raw.githubusercontent.com/emacs-mirror/emacs/emacs-26/lisp/replace.el > >> with > >> the following diff: > >> diff --git a/replace.el b/replace_fixed.el > >> index 08feb8e..8280fdd 100644 > >> --- a/replace.el > >> +++ b/replace_fixed.el > >> @@ -2227,7 +2227,7 @@ It is called with three arguments, as if it were > >> (isearch-forward (not backward)) > >> (isearch-other-end match-beg) > >> (isearch-error nil)) > >> - (isearch-lazy-highlight-new-loop range-beg range-end)))) > >> + (save-match-data (isearch-lazy-highlight-new-loop range-beg > >> range-end))))) > >> (defun replace-dehighlight () > >> (when replace-overlay > >> Then I added the following to my "~/.emacs", restarted my emacs server, and > >> the issue was gone!: > >> (load-library "~/.emacs.d/lisp/replace_fixed.el") > >> This probably isn't the proper fix, but just thought I'd share in case > >> anyone else is experiencing this and wanted a temporary workaround. > > Excellent! To be honest, I was thinking of sending just that workaround > > to you as a temporary patch, but it seems I didn't need to. :-) > > That might well be the fix we end up putting into Emacs, but it might > > not be. Sorry we're so slow, here. > I think first we should try to narrow down the source of this match > data leak. Is there really such a thing as a match data leak? I don't think there's any convention that the match data are preserved over large bits of code, particularly when different libraries are involved. There is nothing documented in the Elisp manual that I can see. > Then we could decide what is the best solution. Currently I see no > such place in isearch-lazy-highlight-new-loop that calls external code. isearch-lazy-highlight-new-loop calls (sit-for 0), which calls redisplay, which calls font locking. > OTOH, while looking at CC-Mode I noticed that it does some matches on > before-change hooks. The bulk of c-before-change is inside a save-match-data, as is the bulk of c-after-change. Other entry points (such as c-font-lock-fontify-region) aren't enclosed in save-match-data. > I could debug it but can't reproduce neither in 26.1 nor in 27, even > with -Q -nw. For what it's worth, I only saw the bug in X Windows, immediately after starting emacs with emacs -Q -nw. A second try with M-% (after the first one has failed) just works. -- Alan Mackenzie (Nuremberg, Germany).