From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jayden Navarro Newsgroups: gmane.emacs.bugs Subject: bug#36328: 26.2; Args out of range on search-and-replace of *.cc file Date: Sat, 22 Jun 2019 15:38:25 -0700 Message-ID: References: <20190622132549.84518.qmail@mail.muc.de> <20190622205033.GA9167@ACM> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000662939058bf13db9" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="236763"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36328@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 23 00:39: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 1heofB-000zTH-Tk for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jun 2019 00:39:14 +0200 Original-Received: from localhost ([::1]:42620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heofA-0004Vl-OG for geb-bug-gnu-emacs@m.gmane.org; Sat, 22 Jun 2019 18:39:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32902) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heof4-0004Vb-Ka for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 18:39:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1heof2-00074i-KZ for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 18:39:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39117) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1heof0-0006vb-2j for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 18:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1heoez-0007L1-Ve for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 18:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jayden Navarro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Jun 2019 22:39:01 +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.156124312728186 (code B ref 36328); Sat, 22 Jun 2019 22:39:01 +0000 Original-Received: (at 36328) by debbugs.gnu.org; 22 Jun 2019 22:38:47 +0000 Original-Received: from localhost ([127.0.0.1]:52661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1heoek-0007KY-FO for submit@debbugs.gnu.org; Sat, 22 Jun 2019 18:38:46 -0400 Original-Received: from mail-lf1-f46.google.com ([209.85.167.46]:39986) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1heoeh-0007KK-63 for 36328@debbugs.gnu.org; Sat, 22 Jun 2019 18:38:45 -0400 Original-Received: by mail-lf1-f46.google.com with SMTP id a9so7422060lff.7 for <36328@debbugs.gnu.org>; Sat, 22 Jun 2019 15:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yugabyte-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=I3R57NPqAb+LJLLBHXfo0zOY8FkrTOPc95scL6eMN3w=; b=DcfB9u1eqXD6eeHU4GZUZWmzZS27Khh4jBOIgY2pxQU0QdgH3VD1v6nTbGu6qJfI7z cfNQGrBfxb9zY63ioHvTEoFVgXC2yb3Ljw143SNjfiMmX+cfTg3OFbqBdRRDD7rxscOg Hkq4w+dTEjeO865zURHUObLe3flr4CKe/JaNWyvDiJppg5XAb4NW3pmDfbvOgx5XBc/Z FGCF22ZsSc5iMgI/h+J62bikjjpAG+VrQE2ajTAHJvr68h9j70qAExSgn8bqyYOXxDix VkoMM0coUxCytyShxrBlIMF8vzrHeJd27//jTeIMHvaZzXKcn4PhTOHJ5PEGuga2iBbz Mcgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=I3R57NPqAb+LJLLBHXfo0zOY8FkrTOPc95scL6eMN3w=; b=QolVvU43C+KLMGSRxM3loKXo/H6MqttvyJevdo2lwAp8B+DKUxxtl1IgHhxP0KFaUK dd+wJZ883d0raeBADhBaut/jeB2SSEfKyzdNyv/KYZ4HEhWX2Fz/ZTImcwljF5gY0trC 7Tpod0bjriP8dKRwAQO/S/OAR0Rbtawmj3VcGDVj/pRI5Sz1kgYAsf3PYqIsVKdnPWrK Zf/aTFBGAvg1LS1FrrI35rp9U2XoPaU5p8UxCfTiKMesWAm+/VVDM7hYvd03zNN0qslT 7BDVN0zyO48qlXNVf/MDgr1Y0wPDR/VzU1Ql/fjjCSl1Syu0o7/EW3T4XQ+pTLgyLYNN 81pQ== X-Gm-Message-State: APjAAAVoS+QTotiyaYdvIUj22KzO6OcqOUrvKCs8GtPICk1aiTfzXwcy qluDUOG78K6JlJTVquoOkeKB/jkjTQThOMmbg7k4VQ== X-Google-Smtp-Source: APXvYqxlSFRsyQDA08b40+5BcBhtP+gNYfOcbMjLmWlfK/X/Y9vgF6Id2kHny1R6MHfRetYpz2mJrD5BKP59z4mu4SA= X-Received: by 2002:ac2:494f:: with SMTP id o15mr42223663lfi.84.1561243117031; Sat, 22 Jun 2019 15:38:37 -0700 (PDT) In-Reply-To: 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:161070 Archived-At: --000000000000662939058bf13db9 Content-Type: text/plain; charset="UTF-8" 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". I could reproduce on the clean VM using: TERM="xterm-256color" emacs -Q test.cc Launching Emacs in that way, and following the other steps given above, should allow you to reproduce. Best, Jayden 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!): > > 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) > > Thank you for your help! > > Best, > Jayden > > > On Sat, Jun 22, 2019 at 1:50 PM Alan Mackenzie wrote: > >> Hello again, Jayden. >> >> On Sat, Jun 22, 2019 at 07:25:30 -0700, Jayden Navarro wrote: >> > Hello Alan, >> >> > Thank you for your response. Apologies for the ambiguous steps. Please >> find >> > more detailed information below: >> >> Thanks! >> >> > Here are the steps: >> >> > 1. Open a file in c++-mode (e.g. emacs -Q test.cc). >> >> > 2. Add 100 lines of some string (e.g. the word "bar" on every line for >> 100 >> > lines, no quotes in the actual file): >> >> > bar >> > bar >> > bar >> > bar >> > ... >> > bar >> >> > 3. Add a unique string to line 101 (e.g. the word "foo", no quotes in >> the >> > actual file). >> >> > bar >> > bar >> > bar >> > bar >> > ... >> > bar >> > foo >> > >> >> > 4. Close Emacs >> >> > 5. Open up the file again: emacs -Q test.cc >> >> > 6. Replace the unique string with some other string: M-x query-replace >> > foo bar >> >> Are you _sure_ that's what you typed? ;-) >> >> > 7. You should hit: Args out of range: #, 0, 1 >> >> > Here's the backtrace when using debug-on-error: >> >> > Debugger entered--Lisp error: (args-out-of-range # 0 1) >> > buffer-substring-no-properties(0 1) <============================== >> > perform-replace("foo" "a" t nil nil nil nil nil nil nil nil) >> > query-replace("foo" "a" nil nil nil nil nil) >> > funcall-interactively(query-replace "foo" "a" nil nil nil nil nil) >> > call-interactively(query-replace nil nil) >> > command-execute(query-replace) >> >> There, it looks like you are trying to replace "foo" by "a". I'm >> interested in the (invalid) arguments 0, 1 passed to >> buffer-substring-no-properties. I suspect that these are derived from >> the "match-data" for a string, in particular for the string "a". >> >> Could you please repeat the bug scenario, but this time try to replace >> "foo" by "bar". I predict you will then get the error message >> >> (args-out-of-range # 0 3) >> >> since the replacement string will then be 3 characters long. >> >> If that does indeed happen, it would be a very strong clue as to the >> underlying bug. Please try it as above, and post the backtrace here. >> Thanks! >> >> [ .... ] >> >> > Here's the list of packages I have installed under $HOME/.emacs.d/elpa: >> >> > avy-0.3.0 >> > company-20181105.2312 >> > company-lean-20171102.1454 >> > dash-20180910.1856 >> > dash-functional-20180107.1618 >> > epl-20180205.2049 >> > f-20180106.922 >> > flycheck-20181127.1510 >> > gnupg >> > go-mode-1.3.1 >> > haskell-mode-13.16 >> > lean-mode-20180906.1645 >> > pkg-info-20150517.1143 >> > rust-mode-20181008.1628 >> > s-20180406.808 >> >> I think, I hope very strongly, that the -Q in emacs -Q will prevent any >> packages being loaded. Otherwise we have a problem in the Emacs core. >> >> > Best, >> > Jayden >> >> -- >> Alan Mackenzie (Nuremberg, Germany). >> > --000000000000662939058bf13db9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I've figured out the trigger! I setup a CentOS 7 VM an= d installed Emacs 26.2.90 and couldn't repro on it. So I compared all t= he 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".

I= could reproduce on the clean VM using:=C2=A0TERM=3D"xterm-256color&qu= ot; emacs -Q test.cc

Launching Emacs in that way, = and following the other steps given above, should allow you to reproduce.

Best,
Jayden


On Sat, Jun 22, 2019 at 2:27 PM Jayden Navarro <jayden@yugabyte.com> wrote:
Hi Alan,
Yes, you are completely correct :-) Posted one thing but uninte= ntionally took a "shortcut" when producing the backtrace (not a s= mart thing to do when trying to get people to repro...).

Here's the backtrace when doing doing M-% foo <RET> bar &l= t;RET> (note that it's still 0, 1 not 0, 3!):

Debugger entered--Lisp error: (args-out-of-range #<buffer test.cc>= 0 1)
=C2=A0 buffer-substring-no-properties(0 1)
=C2=A0 perform-repla= ce("foo" "bar" t nil nil nil nil nil nil nil nil)
= =C2=A0 query-replace("foo" "bar" nil nil nil nil nil)=C2=A0 funcall-interactively(query-replace "foo" "bar"= ; nil nil nil nil nil)
=C2=A0 call-interactively(query-replace nil nil)<= br>=C2=A0 command-execute(query-replace)

Thank you for your help!

Best,
Jayden


On Sat, Jun 22, 2019 at 1:50 PM Alan Mackenzie <acm@muc.de> wrote:
Hello again, Jayden.<= br>
On Sat, Jun 22, 2019 at 07:25:30 -0700, Jayden Navarro wrote:
> Hello Alan,

> Thank you for your response. Apologies for the ambiguous steps. Please= find
> more detailed information below:

Thanks!

> Here are the steps:

> 1. Open a file in c++-mode (e.g. emacs -Q test.cc).

> 2. Add 100 lines of some string (e.g. the word "bar" on ever= y line for 100
> lines, no quotes in the actual file):

> bar
> bar
> bar
> bar
> ...
> bar

> 3. Add a unique string to line 101 (e.g. the word "foo", no = quotes in the
> actual file).

> bar
> bar
> bar
> bar
> ...
> bar
> foo
> <INCLUDE NEWLINE AT END OF FILE>

> 4. Close Emacs

> 5. Open up the file again: emacs -Q test.cc

> 6. Replace the unique string with some other string: M-x query-replace=
> <RET> foo <RET> bar <RET>

Are you _sure_ that's what you typed?=C2=A0 ;-)

> 7. You should hit: Args out of range: #<buffer test.cc>, 0, 1
> Here's the backtrace when using debug-on-error:

> Debugger entered--Lisp error: (args-out-of-range #<buffer test.cc&g= t; 0 1)
>=C2=A0 =C2=A0buffer-substring-no-properties(0 1)=C2=A0 <=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D
>=C2=A0 =C2=A0perform-replace("foo" "a" t nil nil ni= l nil nil nil nil nil)
>=C2=A0 =C2=A0query-replace("foo" "a" nil nil nil ni= l nil)
>=C2=A0 =C2=A0funcall-interactively(query-replace "foo" "= a" nil nil nil nil nil)
>=C2=A0 =C2=A0call-interactively(query-replace nil nil)
>=C2=A0 =C2=A0command-execute(query-replace)

There, it looks like you are trying to replace "foo" by "a&q= uot;.=C2=A0 I'm
interested in the (invalid) arguments 0, 1 passed to
buffer-substring-no-properties.=C2=A0 I suspect that these are derived from=
the "match-data" for a string, in particular for the string "= ;a".

Could you please repeat the bug scenario, but this time try to replace
"foo" by "bar".=C2=A0 I predict you will then get the e= rror message

=C2=A0 =C2=A0 (args-out-of-range #<buffer test.cc> 0 3)

since the replacement string will then be 3 characters long.

If that does indeed happen, it would be a very strong clue as to the
underlying bug.=C2=A0 Please try it as above, and post the backtrace here.<= br> Thanks!

[ .... ]

> Here's the list of packages I have installed under $HOME/.emacs.d/= elpa:

> avy-0.3.0
> company-20181105.2312
> company-lean-20171102.1454
> dash-20180910.1856
> dash-functional-20180107.1618
> epl-20180205.2049
> f-20180106.922
> flycheck-20181127.1510
> gnupg
> go-mode-1.3.1
> haskell-mode-13.16
> lean-mode-20180906.1645
> pkg-info-20150517.1143
> rust-mode-20181008.1628
> s-20180406.808

I think, I hope very strongly, that the -Q in emacs -Q will prevent any
packages being loaded.=C2=A0 Otherwise we have a problem in the Emacs core.=

> Best,
> Jayden

--
Alan Mackenzie (Nuremberg, Germany).
--000000000000662939058bf13db9--