* print.c (Fexternal_debugging_output): Add cast to pacify
--enable-gcc-warnings.
+ * eval.c (call_debugger): Grow specpdl if the debugger was
+ entered due to specpdl overflow (Bug#16603) and allow more
+ specpdl space for the debugger itself.
2014-02-02 Martin Rudalics <rudalics@gmx.at>
max_lisp_eval_depth = XINT (XCDR (data));
}
+static void grow_specpdl (void);
+
/* Call the Lisp debugger, giving it argument ARG. */
Lisp_Object
bool debug_while_redisplaying;
ptrdiff_t count = SPECPDL_INDEX ();
Lisp_Object val;
- EMACS_INT old_max = max_specpdl_size;
-
- /* Temporarily bump up the stack limits,
- so the debugger won't run out of stack. */
-
- max_specpdl_size += 1;
- record_unwind_protect (restore_stack_limits,
- Fcons (make_number (old_max),
- make_number (max_lisp_eval_depth)));
- max_specpdl_size = old_max;
+ EMACS_INT old_max = max_specpdl_size, old_depth = max_lisp_eval_depth;
if (lisp_eval_depth + 40 > max_lisp_eval_depth)
max_lisp_eval_depth = lisp_eval_depth + 40;
- if (max_specpdl_size - 100 < SPECPDL_INDEX ())
- max_specpdl_size = SPECPDL_INDEX () + 100;
+ /* While debugging Bug#16603, previous value of 100 was found
+ too small to avoid specpdl overflow in the debugger itself. */
+ if (max_specpdl_size - 200 < count)
+ max_specpdl_size = count + 200;
+
+ if (old_max == count)
+ {
+ /* We can enter the debugger due to specpdl overflow (Bug#16603). */
+ specpdl_ptr--;
+ grow_specpdl ();
+ }
+
+ /* Restore limits after leaving the debugger. */
+ record_unwind_protect (restore_stack_limits,
+ Fcons (make_number (old_max),
+ make_number (old_depth)));
#ifdef HAVE_WINDOW_SYSTEM
if (display_hourglass_p)