GNU bug report logs - #14156
24.3.50; Timer firing after being canceled

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Date: Mon, 8 Apr 2013 00:55:01 UTC

Severity: normal

Found in version 24.3.50

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14156 in the body.
You can then email your comments to 14156 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to michael_heerdegen <at> web.de, bug-gnu-emacs <at> gnu.org:
bug#14156; Package emacs. (Mon, 08 Apr 2013 00:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
New bug report received and forwarded. Copy sent to michael_heerdegen <at> web.de, bug-gnu-emacs <at> gnu.org. (Mon, 08 Apr 2013 00:55:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; Timer firing after being canceled
Date: Sun, 07 Apr 2013 20:50:37 -0400
[Message part 1 (text/plain, inline)]
Submitting it as a bug-report


        Stefan


[Message part 2 (message/rfc822, inline)]
From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: emacs-devel <at> gnu.org
Cc: Tomohiro Matsuyama <tomo <at> cx4a.org>
Subject: 24.3.50; Timer firing after being canceled
Date: Sun, 07 Apr 2013 21:53:24 +0200
Hi,

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

,----------------------------------------------------------------------
| Hi,
| 
| I have found a problem that cancel-timer will not work in a particular
| situation where the timer takes more time to execute than a
| rescheduling interval of the timer.  Here is the reproducible code:
| 
|     (setq my-timer
|           (run-with-timer
|            nil 0.1
|            (lambda ()
|              (when my-timer
|                (cancel-timer my-timer)
|                (setq my-timer nil)
|                (sit-for 0.3)))))
| 
| After evaluating this code several times, you may see "zombie" timers
| in timer-list, though the code intends to keep at most one timer.
`----------------------------------------------------------------------

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.


Thanks,

Michael.



In GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.4.2)
 of 2013-04-04 on dex, modified by Debian
 (emacs-snapshot package, version 2:20130403-1)
Windowing system distributor `The X.Org Foundation', version 11.0.11204000
System Description:	Debian GNU/Linux 7.0 (wheezy)

Configured using:
 `configure --build x86_64-linux-gnu --host x86_64-linux-gnu
 --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var --infodir=/usr/share/info --mandir=/usr/share/man
 --with-pop=yes
 --enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.3.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3.50/site-lisp:/usr/share/emacs/site-lisp
 --without-compress-info --with-crt-dir=/usr/lib/x86_64-linux-gnu/
 --with-x=yes --with-x-toolkit=gtk3 --with-imagemagick=yes
 CFLAGS='-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2'
 CPPFLAGS='-D_FORTIFY_SOURCE=2' LDFLAGS='-g -Wl,--as-needed
 -znocombreloc''

Important settings:
  value of $LC_ALL: de_DE.utf8
  value of $LC_TIME: C
  value of $LANG: de_DE.utf8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Dired by name


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14156; Package emacs. (Mon, 08 Apr 2013 02:13:02 GMT) Full text and rfc822 format available.

Message #8 received at 14156 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 14156 <at> debbugs.gnu.org
Subject: Re: 24.3.50; Timer firing after being canceled
Date: Sun, 07 Apr 2013 22:09:01 -0400
> If you call `start-the-timer', you get the message "Why is this ever
> reached?" over and over.  This obviously should not happen.

As mentioned elsewhere, this seems to be due to patch

   revno: 110138
   fixes bugs: http://debbugs.gnu.org/12447 http://debbugs.gnu.org/12326

I installed the patch below which seems to fix it.


        Stefan


=== modified file 'lisp/emacs-lisp/timer.el'
--- lisp/emacs-lisp/timer.el	2013-01-13 01:23:48 +0000
+++ lisp/emacs-lisp/timer.el	2013-04-08 01:53:53 +0000
@@ -314,7 +314,11 @@
               (save-current-buffer
                 (apply (timer--function timer) (timer--args timer)))
 	    (error (message "Error in timer: %S" err)))
-	  (if retrigger
+	  (when (and retrigger
+                     ;; If the timer's been canceled, don't "retrigger" it
+                     ;; since it might still be in the copy of timer-list kept
+                     ;; by keyboard.c:timer_check (bug#14156).
+                     (memq timer timer-list))
 	      (setf (timer--triggered timer) nil)))
       (error "Bogus timer event"))))
 





bug closed, send any further explanations to 14156 <at> debbugs.gnu.org and Stefan Monnier <monnier <at> IRO.UMontreal.CA> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 27 Apr 2013 00:30:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 25 May 2013 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 32 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.