emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 24.3.50; Timer firing after being canceled


From: Stefan Monnier
Subject: Re: 24.3.50; Timer firing after being canceled
Date: Sun, 07 Apr 2013 18:47:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> This report is about the following problem (bug) raised in
> gnu.emacs.devel by Tomohiro Matsuyama:

AFAICT you sent it to emacs-devel rather than to bug-gnu-emacs, so it's
not "a report".

> I can reproduce this problem.  And I have a test case that proves that
> timers that have been canceled (i.e., removed from `timer-list') are
> still called from C:
> --8<---------------cut here---------------start------------->8---
> (defvar my-timer nil)
> (defun start-the-timer ()
>   (interactive)
>   (setq my-timer
>         (run-with-timer
>          0 0.1
>          (lambda ()
>            (cancel-timer my-timer)
>            (sit-for 0.3)))))

> (advice-add 'timer-event-handler :before
>             (lambda (timer)
>               (when (and (eq timer my-timer)
>                          (not (memq my-timer timer-list)))
>                 (message "Why is this ever reached?"))))
> --8<---------------cut here---------------end--------------->8---
> If you call `start-the-timer', you get the message "Why is this ever
> reached?" over and over.  This obviously should not happen.

IIUC this is a consequence of the patch below.


        Stefan


revno: 110138
fixes bugs: http://debbugs.gnu.org/12447 http://debbugs.gnu.org/12326
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sat 2012-09-22 16:16:03 +0300
message:
  Fix bugs #12447 and #12326 with infloop causes by idle timers, update docs.
  
   src/keyboard.c (timer_check_2): Move calculation of 'timers' and
   'idle_timers' from here ...
   (timer_check): ... to here.  Use Fcopy_sequence to copy the timer
   lists, to avoid infloops when the timer does something stupid,
   like reinvoke itself with the same or smaller time-out.
  
   lisp/emacs-lisp/timer.el (run-with-idle-timer)
   (timer-activate-when-idle): Warn against reinvoking an idle timer
   from within its own timer action.
  
   doc/lispref/os.texi (Idle Timers): Warn against reinvoking an idle timer
   from within its own timer action.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]