From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#16796: 24.3.50; global value of after-change-functions reset without error Date: Tue, 18 Feb 2014 18:43:36 +0100 Message-ID: <87a9douxiv.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1392746049 14547 80.91.229.3 (18 Feb 2014 17:54:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Feb 2014 17:54:09 +0000 (UTC) To: 16796@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 18 18:54:16 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WFos2-0003U5-Cn for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Feb 2014 18:54:14 +0100 Original-Received: from localhost ([::1]:52418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFos1-0004cA-VW for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Feb 2014 12:54:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WForr-0004at-Pq for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2014 12:54:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WForp-0004OS-BF for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2014 12:54:03 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WForp-0004Ny-7z for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2014 12:54:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WFoj8-0006mf-DB for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2014 12:45:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Feb 2014 17:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 16796 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.139274547826031 (code B ref -1); Tue, 18 Feb 2014 17:45:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Feb 2014 17:44:38 +0000 Original-Received: from localhost ([127.0.0.1]:58752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WFoij-0006lk-FD for submit@debbugs.gnu.org; Tue, 18 Feb 2014 12:44:38 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46350) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WFoih-0006lW-Qf for submit@debbugs.gnu.org; Tue, 18 Feb 2014 12:44:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFoiQ-0000vP-GE for submit@debbugs.gnu.org; Tue, 18 Feb 2014 12:44:30 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:33236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFoiQ-0000vI-Dj for submit@debbugs.gnu.org; Tue, 18 Feb 2014 12:44:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFoiB-0007m5-Mq for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2014 12:44:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFohu-0000jV-Bw for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2014 12:44:03 -0500 Original-Received: from mout.web.de ([212.227.15.14]:55244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFohu-0000iy-1s for bug-gnu-emacs@gnu.org; Tue, 18 Feb 2014 12:43:46 -0500 Original-Received: from drachen.dragon ([90.186.103.16]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0MbQfs-1WYaXj1nhU-00IiEN for ; Tue, 18 Feb 2014 18:43:44 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Provags-ID: V03:K0:Lu64lNkL+RJ/oFM4ntsNSaHf8eNV4Y+liaYgpm6S3aFQHUrHGqW 4iP1U5DViWiXYeoUgWuXqbowVudARG20dAUPZVWWuNYsK2z0Vi0eidRlT6ZuBcwfbmWgqtr 2eMPozfxnQflecS9DLvNUjwWnXskhBOYky17v72W3NvDerrOquaXFUSOdYijBWpe1e1IalK 3tecKd/l3FGhJa3FW9gig== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:85835 Archived-At: Hello, I'm working on a package that needs to install a function in (the global binding of) `after-change-functions'. I experience that the global value of `after-change-functions' is randomly reset to nil, without any error involved or any error message being printed. I invested lots of time to preclude any error. I installed a timer that frequently checks whether `after-change-functions' had been reset. A good situation to provoke the reset was completing with helm and just typing in the minibuffer. At random locations, the reset happened. Note that there is no error involved, nor does helm touch `after-change-functions'. Here is a different example that "works" from emacs -Q: --8<---------------cut here---------------start------------->8--- (progn (defun foo (&rest _) ()) (add-hook 'after-change-functions 'foo) (defun complain () (when (not (memq 'foo (default-value 'after-change-functions))) (message "Why does this happen?") (cancel-timer complain-timer))) (defvar complain-timer (run-with-idle-timer .03 .03 #'complain)) (require 'cl-lib) (global-set-key [f9] (lambda () (interactive) (completing-read "Hit tab and C-g: " (cl-loop for i from 1 to 100000 collect (format "%d" i)))))) --8<---------------cut here---------------end--------------->8--- Hit f9 and C-g one or two times. I get "Why does this happen?", but not always. If I repeat the test several times, I'll always happen sooner or later. Here is the response I got from Kalle Olavi Niemitalo in emacs dev: I debugged this a bit, with my custom Emacs 23.0.51. I don't know how much this machinery has changed in later versions. Emacs set Vquit_flag at: handle_interrupt tty_read_avail_input read_avail_input handle_async_input input_available_signal mark_object Fgarbage_collect Ffuncall run_hook_list_with_args signal_after_change Fadd_text_properties Fput_text_property Fdisplay_completion_list internal_with_output_to_temp_buffer Fminibuffer_completion_help do_completion Fminibuffer_complete Ffuncall Fcall_interactively After Fgarbage_collect returned, Ffuncall called funcall_lambda, in which the QUIT macro detected the non-nil value of Vquit_flag and called Fsignal (Qquit, Qnil). Because the quit was signaled within signal_after_change, after-change-functions were not restored. I don't see any reasonable way to prevent after-change-functions from being reset like this. Thanks! Kalle, does that mean that it won't be possible to fix this, and that I shouldn't rely on `after-change-functions' being kept? Do you know whether the buffer local binding is "safe"? Perhaps you could change your Emacs to break when the reset happens, and always run it in a debugger. Make signal_before_change and signal_after_change maintain some kind of flag or nesting counter, and set conditional breakpoints in Fthrow and Fsignal. That will get a false positive if the error is caught within the hook; but I don't think it happens often. Uff, I'm afraid I must say that this is a bit above my (zerop) C skills. Thanks, Michael. In GNU Emacs 24.3.50.6 (x86_64-unknown-linux-gnu, GTK+ Version 3.8.6) of 2014-02-12 on drachen Windowing system distributor `The X.Org Foundation', version 11.0.11405000 System Description: Debian GNU/Linux testing (jessie)