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: Sun, 23 Jun 2019 12:22:07 +0000 Message-ID: <20190623122207.GA4736@ACM> References: <20190622132549.84518.qmail@mail.muc.de> <20190622205033.GA9167@ACM> 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="103918"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 36328@debbugs.gnu.org To: Jayden Navarro Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 23 14:23:14 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 1hf1Wc-000Qtm-3t for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jun 2019 14:23:14 +0200 Original-Received: from localhost ([::1]:44586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hf1Wb-0007Hz-4y for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jun 2019 08:23:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43160) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hf1WV-0007Hd-As for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2019 08:23:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hf1WT-0007xc-9r for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2019 08:23:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39447) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hf1WQ-0007oY-Av for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2019 08:23:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hf1WQ-0000HN-5I for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2019 08:23: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: Sun, 23 Jun 2019 12:23: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.15612925351008 (code B ref 36328); Sun, 23 Jun 2019 12:23:02 +0000 Original-Received: (at 36328) by debbugs.gnu.org; 23 Jun 2019 12:22:15 +0000 Original-Received: from localhost ([127.0.0.1]:52990 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hf1Ve-0000GC-LQ for submit@debbugs.gnu.org; Sun, 23 Jun 2019 08:22:14 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:26704 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hf1VZ-0000Fz-Vi for 36328@debbugs.gnu.org; Sun, 23 Jun 2019 08:22:10 -0400 Original-Received: (qmail 37261 invoked by uid 3782); 23 Jun 2019 12:22:08 -0000 Original-Received: from acm.muc.de (p2E5D5B98.dip0.t-ipconnect.de [46.93.91.152]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 23 Jun 2019 14:22:07 +0200 Original-Received: (qmail 5768 invoked by uid 1000); 23 Jun 2019 12:22:07 -0000 Content-Disposition: inline In-Reply-To: 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:161102 Archived-At: Hello, Jayden. On Sat, Jun 22, 2019 at 15:38:25 -0700, Jayden Navarro wrote: > I've figured out the trigger! I setup a CentOS 7 VM and installed Emacs > 26.2.90 and couldn't repro on it. So I compared all the environment > variables between Cygwin and the VM and performed some tests, and > discovered the issue is triggered by my "TERM" environment variable being > set to "xterm-256color". Well done! > I could reproduce on the clean VM using: TERM="xterm-256color" emacs -Q > test.cc In my X-Windows setup, an xterm has the setting of TERM anyway. So I was able to reproduce the failure with emacs -Q -nw. -nw means "no windows", i.e. run in the terminal, not as a GUI application. (Normally, I run Emacs in a linux virtual terminal.) > Launching Emacs in that way, and following the other steps given above, > should allow you to reproduce. Yes. It didn't take me too long to track down where it's going wrong. `perform-replace' calls `replace-highlight' to highlight the "foo", and this calls `isearch-lazy-highlight-new-loop'. This in its turn performs a redisplay (which is probably where CC Mode affects things). It seems too much to expect that the "match-data" will be preserved over all this activity, but `perform-replace' does expect this. To fix this will involve putting a `save-match-data' around some form somewhere. Please allow us some time to decide where this would be best. > On Sat, Jun 22, 2019 at 2:27 PM Jayden Navarro wrote: > > Hi Alan, > > Yes, you are completely correct :-) Posted one thing but unintentionally > > took a "shortcut" when producing the backtrace (not a smart thing to do > > when trying to get people to repro...). > > Here's the backtrace when doing doing M-% foo bar (note that > > it's still 0, 1 not 0, 3!): I still have no specific idea what's generating that 0 and 1. Will probably never find out. > > Debugger entered--Lisp error: (args-out-of-range # 0 1) > > buffer-substring-no-properties(0 1) > > perform-replace("foo" "bar" t nil nil nil nil nil nil nil nil) > > query-replace("foo" "bar" nil nil nil nil nil) > > funcall-interactively(query-replace "foo" "bar" nil nil nil nil nil) > > call-interactively(query-replace nil nil) > > command-execute(query-replace) > Best, > Jayden -- Alan Mackenzie (Nuremberg, Germany).