Subject: Re: bug#16796: 24.3.50; global value of after-change-functions reset without error

From: Alex <[email-masked]>
Date: Thu, 08 Sep 2016 17:47:50 -0600

Michael Heerdegen <[email-masked]> writes:

> 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:
>
> (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))))))
>
> 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.

I can reproduce this on 24.5 but not in 25.1. Can you reproduce this on 25.1
or up?