From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: 24.3.50; Timer firing after being canceled Date: Sun, 07 Apr 2013 18:47:03 -0400 Message-ID: References: <87ip3yw217.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1365445677 4354 80.91.229.3 (8 Apr 2013 18:27:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Apr 2013 18:27:57 +0000 (UTC) Cc: Tomohiro Matsuyama To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 08 20:28:01 2013 Return-path: Envelope-to: ged-emacs-devel@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 1UPGnP-0000pw-7X for ged-emacs-devel@m.gmane.org; Mon, 08 Apr 2013 20:27:59 +0200 Original-Received: from localhost ([::1]:35316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UOyMq-0005Ks-6Y for ged-emacs-devel@m.gmane.org; Sun, 07 Apr 2013 18:47:20 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UOyMh-0005Ju-6w for emacs-devel@gnu.org; Sun, 07 Apr 2013 18:47:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UOyMa-0003Pj-JX for emacs-devel@gnu.org; Sun, 07 Apr 2013 18:47:11 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:2654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UOyMa-0003Pc-El for emacs-devel@gnu.org; Sun, 07 Apr 2013 18:47:04 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFxLSu/2dsb2JhbABEvw4Xc4IeAQEEAScvIwULCzQSFBgNN4gLBsEtjWGDKQOLUotXhUCEYIMxgV6DE4FKBA X-IPAS-Result: Av4EABK/CFFFxLSu/2dsb2JhbABEvw4Xc4IeAQEEAScvIwULCzQSFBgNN4gLBsEtjWGDKQOLUotXhUCEYIMxgV6DE4FKBA X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="6783949" Original-Received: from 69-196-180-174.dsl.teksavvy.com (HELO pastel.home) ([69.196.180.174]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 07 Apr 2013 18:47:00 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 22C4D67A13; Sun, 7 Apr 2013 18:47:03 -0400 (EDT) In-Reply-To: <87ip3yw217.fsf@web.de> (Michael Heerdegen's message of "Sun, 07 Apr 2013 21:53:24 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:158769 Archived-At: > 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 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.