unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Tomohiro Matsuyama <tomo@cx4a.org>
Subject: Re: 24.3.50; Timer firing after being canceled
Date: Sun, 07 Apr 2013 18:47:03 -0400	[thread overview]
Message-ID: <jwvmwtayno0.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87ip3yw217.fsf@web.de> (Michael Heerdegen's message of "Sun, 07 Apr 2013 21:53:24 +0200")

> 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 <eliz@gnu.org>
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	other threads:[~2013-04-07 22:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-07 19:53 24.3.50; Timer firing after being canceled Michael Heerdegen
2013-04-07 22:47 ` Stefan Monnier [this message]
2013-04-08 20:12   ` `report-emacs-bug' and mail-user-agent (was: 24.3.50; Timer firing after being canceled) Michael Heerdegen
2013-04-08 21:29     ` `report-emacs-bug' and mail-user-agent Stefan Monnier
2013-04-09 12:24       ` Michael Heerdegen
2013-04-09 13:23         ` Stefan Monnier
2013-04-09 14:20           ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvmwtayno0.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=tomo@cx4a.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).