From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov 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 22:18:53 +0300 Organization: LINKOV.NET Message-ID: <87d0j27wiu.fsf@mail.linkov.net> References: <20190622132549.84518.qmail@mail.muc.de> <20190622205033.GA9167@ACM> <20190623122207.GA4736@ACM> <20190623193258.GB4736@ACM> <87k1dc2e5h.fsf@mail.linkov.net> <20190624075218.GA4781@ACM> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="29818"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: Jayden Navarro , 36328@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 24 21:22:37 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 1hfUXy-0007bB-5R for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Jun 2019 21:22:34 +0200 Original-Received: from localhost ([::1]:54132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfUXx-000772-4p for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Jun 2019 15:22:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46267) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfUXT-0006WY-VF for bug-gnu-emacs@gnu.org; Mon, 24 Jun 2019 15:22:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfUXS-0006Iz-U1 for bug-gnu-emacs@gnu.org; Mon, 24 Jun 2019 15:22:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44469) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfUXS-0006Io-QC for bug-gnu-emacs@gnu.org; Mon, 24 Jun 2019 15:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hfUXS-0003pN-Ee for bug-gnu-emacs@gnu.org; Mon, 24 Jun 2019 15:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Jun 2019 19:22: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.156140407714624 (code B ref 36328); Mon, 24 Jun 2019 19:22:02 +0000 Original-Received: (at 36328) by debbugs.gnu.org; 24 Jun 2019 19:21:17 +0000 Original-Received: from localhost ([127.0.0.1]:58012 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfUWi-0003no-WC for submit@debbugs.gnu.org; Mon, 24 Jun 2019 15:21:17 -0400 Original-Received: from beige.elm.relay.mailchannels.net ([23.83.212.16]:64092) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfUWg-0003nd-R0 for 36328@debbugs.gnu.org; Mon, 24 Jun 2019 15:21:15 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B1EB81A2D58; Mon, 24 Jun 2019 19:21:13 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com (100-96-28-110.trex.outbound.svc.cluster.local [100.96.28.110]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 058771A28A8; Mon, 24 Jun 2019 19:21:13 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.2); Mon, 24 Jun 2019 19:21:13 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Blushing-Harbor: 067f68ae51c9b44d_1561404073385_2401807788 X-MC-Loop-Signature: 1561404073385:603578010 X-MC-Ingress-Time: 1561404073385 Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a62.g.dreamhost.com (Postfix) with ESMTP id 58282818FE; Mon, 24 Jun 2019 12:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=IslkyALSgMi9jPrvcVwl0/qh6Ns=; b= l18I55g4hh1kuxbtiHVteIJ9WSTFpO602gVjo0SdRGQEaLUnPVa14pGYorOlw607 +H8HP7qbKyS5D+rbHPijnDxYQ7qXei0y/VPJCVpP0j+EAy8QxBU8kuRon4n5ETGh zAjyLmqpIvAqLPuEcpm/Qw7cF28N/VYkY97IFN2D+XM= Original-Received: from mail.jurta.org (m91-129-109-209.cust.tele2.ee [91.129.109.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a62.g.dreamhost.com (Postfix) with ESMTPSA id BD14481902; Mon, 24 Jun 2019 12:21:06 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a62 In-Reply-To: <20190624075218.GA4781@ACM> (Alan Mackenzie's message of "Mon, 24 Jun 2019 07:52:18 +0000") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduvddruddvgddugedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdelrddvtdelnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtledrvddtledprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegrtghmsehmuhgtrdguvgenucevlhhushhtvghrufhiiigvpedu 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:161269 Archived-At: Hello, Alan. >> 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. Yes, it seems such match-data leak is considered at least undesirable. I remember efforts to replace string-match with string-match-p in potentially unsafe places and to wrap more code in save-match-data. But I guess such efforts are futile since this task is endless. Usually it's enough for a function that cares about preserving match-data to protect it from mutation. >> 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. You are right that it's too much to expect that the match-data will be preserved after redisplay, and we can't find and fix all places that change match-data, so save-match-data needs be added to perform-replace somewhere to protect match-data. Since (sit-for 0) is unsafe for match-data, the first candidate to be wrapped in save-match-data is (sit-for 0) itself in isearch-lazy-highlight-new-loop. But perhaps more correct would be to use save-match-data in the same function that cares about preserving its match-data, so the second candidate to use save-match-data is perform-replace. Then the need of using save-match-data will be self-evident for everyone who will look at the code in perform-replace: here we use match-data, and here we protect it in the same function.