aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorDmitry Antipov2014-02-03 13:37:43 +0400
committerDmitry Antipov2014-02-03 13:37:43 +0400
commit9cad4576df88d17c2234c8f04f05dac279e57b22 (patch)
tree01eb9a6e16e2dd6e476cd38ab0adcae2ebae5a0c /src/eval.c
parent7bcbca405fcab0cec6629856e9eeec8f97fd0a7d (diff)
downloademacs-9cad4576df88d17c2234c8f04f05dac279e57b22.tar.gz
emacs-9cad4576df88d17c2234c8f04f05dac279e57b22.zip
* 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.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c31
1 files changed, 19 insertions, 12 deletions
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)
273 max_lisp_eval_depth = XINT (XCDR (data)); 273 max_lisp_eval_depth = XINT (XCDR (data));
274} 274}
275 275
276static void grow_specpdl (void);
277
276/* Call the Lisp debugger, giving it argument ARG. */ 278/* Call the Lisp debugger, giving it argument ARG. */
277 279
278Lisp_Object 280Lisp_Object
@@ -281,22 +283,27 @@ call_debugger (Lisp_Object arg)
281 bool debug_while_redisplaying; 283 bool debug_while_redisplaying;
282 ptrdiff_t count = SPECPDL_INDEX (); 284 ptrdiff_t count = SPECPDL_INDEX ();
283 Lisp_Object val; 285 Lisp_Object val;
284 EMACS_INT old_max = max_specpdl_size; 286 EMACS_INT old_max = max_specpdl_size, old_depth = max_lisp_eval_depth;
285
286 /* Temporarily bump up the stack limits,
287 so the debugger won't run out of stack. */
288
289 max_specpdl_size += 1;
290 record_unwind_protect (restore_stack_limits,
291 Fcons (make_number (old_max),
292 make_number (max_lisp_eval_depth)));
293 max_specpdl_size = old_max;
294 287
295 if (lisp_eval_depth + 40 > max_lisp_eval_depth) 288 if (lisp_eval_depth + 40 > max_lisp_eval_depth)
296 max_lisp_eval_depth = lisp_eval_depth + 40; 289 max_lisp_eval_depth = lisp_eval_depth + 40;
297 290
298 if (max_specpdl_size - 100 < SPECPDL_INDEX ()) 291 /* While debugging Bug#16603, previous value of 100 was found
299 max_specpdl_size = SPECPDL_INDEX () + 100; 292 too small to avoid specpdl overflow in the debugger itself. */
293 if (max_specpdl_size - 200 < count)
294 max_specpdl_size = count + 200;
295
296 if (old_max == count)
297 {
298 /* We can enter the debugger due to specpdl overflow (Bug#16603). */
299 specpdl_ptr--;
300 grow_specpdl ();
301 }
302
303 /* Restore limits after leaving the debugger. */
304 record_unwind_protect (restore_stack_limits,
305 Fcons (make_number (old_max),
306 make_number (old_depth)));
300 307
301#ifdef HAVE_WINDOW_SYSTEM 308#ifdef HAVE_WINDOW_SYSTEM
302 if (display_hourglass_p) 309 if (display_hourglass_p)