Subject: bug#30182: Update

From: martin rudalics <[email-masked]>
Date: Wed, 31 Jan 2018 10:31:38 +0100

> How about running the code with a watchpoint on Vtimer_alist?  Could
 > that help?

That hardly sounds like an amusing experience with all those timers
around.  Sujith, could you instead try the attached patch and tell us
what happens.

Thanks, martin
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 6082344..40e5ada 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -136,7 +136,7 @@ mode-line-default-help-echo
           ;; at the bottom of its frame or the minibuffer window of
           ;; this frame can be resized.  This matches a corresponding
           ;; check in `mouse-drag-mode-line'.
-          (or (not (window-at-side-p window 'bottom))
+          (or (window-in-direction 'below window)
               (let ((mini-window (minibuffer-window frame)))
                 (and (eq frame (window-frame mini-window))
                      (or (minibuffer-window-active-p mini-window)
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index b1e12b1..3d280a9 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -171,6 +171,11 @@ timer--activate
 	   (timer--function timer))
       (let ((timers (if idle timer-idle-list timer-list))
 	    last)
+
+        (when (and (not idle) timer-check-in-progress)
+          (error "Attempt to add %s to %s while checking timers"
+                 timer timers))
+
 	;; Skip all timers to trigger before the new one.
 	(while (and timers (timer--time-less-p (car timers) timer))
 	  (setq last timers
diff --git a/src/keyboard.c b/src/keyboard.c
index 75fbe45..4324991 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -4378,7 +4378,9 @@ struct timespec
      already ripe when added.  */
 
   /* Always consider the ordinary timers.  */
+  Vtimer_check_in_progress = Qt;
   timers = Fcopy_sequence (Vtimer_list);
+  Vtimer_check_in_progress = Qnil;
   /* Consider the idle timers only if Emacs is idle.  */
   if (timespec_valid_p (timer_idleness_start_time))
     idle_timers = Fcopy_sequence (Vtimer_idle_list);
@@ -11880,6 +11882,11 @@ shutdown when Emacs receives a fatal signal (e.g., a crash).
                Vwhile_no_input_ignore_events,
                doc: /* Ignored events from while-no-input.  */);
   Vwhile_no_input_ignore_events = Qnil;
+
+  DEFVAR_LISP ("timer-check-in-progress",
+               Vtimer_check_in_progress,
+               doc: /* Non-nil means a timer check is performed.  */);
+  Vtimer_check_in_progress = Qnil;
 }
 
 void