From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Newsgroups: gmane.emacs.bugs Subject: bug#39585: after-change-functions called with invalid positions in call-process Date: Wed, 12 Feb 2020 22:56:49 -0500 Message-ID: <0a3d3423-965f-4681-b6e2-04b8c1a36a6a@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="130457"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 Cc: Alan Mackenzie To: 39585@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 13 04:57:11 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 1j25cl-000XnR-Ec for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Feb 2020 04:57:11 +0100 Original-Received: from localhost ([::1]:47048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j25ck-0006CF-6w for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Feb 2020 22:57:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34435) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j25ce-0006C9-9p for bug-gnu-emacs@gnu.org; Wed, 12 Feb 2020 22:57:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j25cd-0004tc-3B for bug-gnu-emacs@gnu.org; Wed, 12 Feb 2020 22:57:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53287) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j25cd-0004tT-00 for bug-gnu-emacs@gnu.org; Wed, 12 Feb 2020 22:57:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j25cc-0006GL-EW; Wed, 12 Feb 2020 22:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-Sender: "Debbugs-submit" Resent-CC: acm@muc.de, bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Feb 2020 03:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39585 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs X-Debbugs-Original-Xcc: Alan Mackenzie Original-Received: via spool by submit@debbugs.gnu.org id=B.158156621624056 (code B ref -1); Thu, 13 Feb 2020 03:57:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Feb 2020 03:56:56 +0000 Original-Received: from localhost ([127.0.0.1]:59259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j25cW-0006Fw-HX for submit@debbugs.gnu.org; Wed, 12 Feb 2020 22:56:56 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:35287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j25cV-0006Fp-1Q for submit@debbugs.gnu.org; Wed, 12 Feb 2020 22:56:55 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34410) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j25cT-0006BN-OF for bug-gnu-emacs@gnu.org; Wed, 12 Feb 2020 22:56:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j25cS-0004kt-J3 for bug-gnu-emacs@gnu.org; Wed, 12 Feb 2020 22:56:53 -0500 Original-Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:32957) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j25cS-0004kM-Dl for bug-gnu-emacs@gnu.org; Wed, 12 Feb 2020 22:56:52 -0500 Original-Received: by mail-qk1-x736.google.com with SMTP id h4so4450887qkm.0 for ; Wed, 12 Feb 2020 19:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=EDbRcgoieR85ItIjV7+TwnQGY7Ys49UriPigWjeZbb0=; b=c4Qx8eohJLMNPaDO0QhFo9J7yW9+SherktC6npkOx4X7EjbtjsyxEVg/Loj7A6mS+1 Yn5gOds4Hu3h9hbTknhY2dtwiYRI5ezQrT6EEtwvs9i5mgRqXWXzdruyMh4JWtaR2a+A 222+vOGjSiHVfrCEf4Yy3rI7tq+Iw0Gtr0wYKv7zjMF+dr6m9+coqpW60fe5pcjDHogv 76BNNy/XuxSyXEeGYHfS3i1GxBwYqyasQ0GDDvUGE02uZhQLTIAFNR6f/z2PvDunjzNr YyXmg7TqgFCSLtYyIRkcnNZhk11Ry4NckecEBQxNvxmMPZHjMFNwXqc1uGQIPOWy4ApQ N72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=EDbRcgoieR85ItIjV7+TwnQGY7Ys49UriPigWjeZbb0=; b=Zn17o7KogNk8NaAEM96Fjhb1ydQcAYBdn+OMoRestsGy352JR0lGGit5FuXiK47YqH +u5CUnVpOfeR0W7qpg8ltDLmu6MCaGyAkxULneAWErhwEvUaTQ6RE7BxdL5Ppb0OWvl8 /TTm5eQ4be7zza56/iHSPezg5rVHTGFjoC+ke+79AwQleGqkGg0hnOYaPHlWHCQ+7jSh 7yHq6Cpdh56tts13r27wI+6t60MRlWe/zcmfRHiDre1wv8+ilpvCN05pRm6l2gqJrXs3 AfNBTzZjvtMkXAYnsJxO1Eh7XAFEgAV9C7Xy1aaQ0SZmdK45tQxzNetM/dEfXT7m34zx tU7Q== X-Gm-Message-State: APjAAAVoGC4MudMcSxOFs7Ealc/StaWOF7QRzUargMYtYsXzYMX4cT3+ U3KinxrLBoa0+SU0dEqn8FOH7vVE X-Google-Smtp-Source: APXvYqzOOapi9S7vU+8eS+WaahFzdB2yuwIvWMxfZQUjP1vUR/qZS1q3BtlsH1FeC+GGKZ+2H0UVrg== X-Received: by 2002:a37:9c10:: with SMTP id f16mr9165753qke.275.1581566211053; Wed, 12 Feb 2020 19:56:51 -0800 (PST) Original-Received: from ?IPv6:2601:184:4180:66e7:141d:589c:d2c9:6cf0? ([2601:184:4180:66e7:141d:589c:d2c9:6cf0]) by smtp.googlemail.com with ESMTPSA id 89sm575163qth.3.2020.02.12.19.56.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Feb 2020 19:56:50 -0800 (PST) Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:175991 Archived-At: Hi all, Recent changes in call-process have introduced surprising behavior in after-change-functions (and caused bugs in flycheck, e.g. https://github.com/flycheck/flycheck/issues/1677). From the documentation, I expected that functions added to the after-change-functions hook would be called only with valid positions. However, the following snippets shows that it's not the case: (defun ~/after-change (beg end len) (message "(after-change %S %S %S); (buffer %S %S %S)" beg end len (point-min) (point-max) (buffer-size))) (with-current-buffer (get-buffer-create "*tmp*") (make-variable-buffer-local 'after-change-functions) (add-hook 'after-change-functions #'~/after-change) (call-process "echo" nil t t "Hello")) Running it repeatedly, this is what I observe: (after-change 7 13 0); (buffer 1 7 6) (after-change 13 19 0); (buffer 1 13 12) (after-change 19 25 0); (buffer 1 19 18) (after-change 25 31 0); (buffer 1 25 24) Note how each time the after-change-functions hook is called with a region past the end of the buffer. It's as if after-change-functions was in fact call right before the insertion, instead of after. Previous versions of Emacs didn't call after-change-functions in this case; it seems that the new behavior was introduced by this commit: commit 224e8d146485ce178086549d41fa8359dcc0e03e Author: Alan Mackenzie Date: Wed Jan 22 19:50:30 2020 +0000 Make call_process call signal_after_change. This fixes bug #38691. Now, functions such as call-proess-region invoke after-change-functions correctly. * src/callproc.c (call_process): Call prepare_to_modify_buffer in a single place, no longer delegating the task to insert_1_both, etc. Call signal_after_change in each of two code branches, such that before-change-functions and after-change-functions are always called in balanced pairs. Alan, is this behavior expected? Thanks, Clément.