From: Dmitry Antipov Date: Mon, 3 Feb 2014 09:37:43 +0000 (+0400) Subject: * eval.c (call_debugger): Grow specpdl if the debugger was X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~181 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9cad4576df88d17c2234c8f04f05dac279e57b22;p=emacs.git * 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 517b3129a22..ac41dabafcd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,9 @@ * 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 diff --git a/src/eval.c b/src/eval.c index 91b8d17769d..da68a3014dd 100644 --- a/src/eval.c +++ b/src/eval.c @@ -273,6 +273,8 @@ restore_stack_limits (Lisp_Object data) max_lisp_eval_depth = XINT (XCDR (data)); } +static void grow_specpdl (void); + /* Call the Lisp debugger, giving it argument ARG. */ Lisp_Object @@ -281,22 +283,27 @@ call_debugger (Lisp_Object arg) 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)