Subject: bug#16603: 24.3.50; Segfault when viewing a backtrace

From: Dmitry Antipov <[email-masked]>
Date: Mon, 10 Feb 2014 13:30:59 +0400

On 02/10/2014 10:37 AM, Lars Ingebrigtsen wrote:

> I do
>
> (require 'gnus-group)
> (setq debug-on-error t)
> (gnus-read-ephemeral-emacs-bug-group 16577)
>
> select Rotem's article, `q' out of the backtrace, `g' Rotem's article,
> and I either get a segfault then, or after repeating this a couple of
> times.

OK, I've got it.

Can you try this?

Dmitry

=== modified file 'src/eval.c'
--- src/eval.c	2014-02-03 09:37:43 +0000
+++ src/eval.c	2014-02-10 09:19:39 +0000
@@ -283,7 +283,9 @@
   bool debug_while_redisplaying;
   ptrdiff_t count = SPECPDL_INDEX ();
   Lisp_Object val;
-  EMACS_INT old_max = max_specpdl_size, old_depth = max_lisp_eval_depth;
+  EMACS_INT old_depth = max_lisp_eval_depth;
+  /* Do not allow max_specpdl_size less than actual depth (Bug#16603).  */
+  EMACS_INT old_max = max (max_specpdl_size, count);
 
   if (lisp_eval_depth + 40 > max_lisp_eval_depth)
     max_lisp_eval_depth = lisp_eval_depth + 40;
@@ -3721,7 +3723,9 @@
 an error is signaled.
 You can safely use a value considerably larger than the default value,
 if that proves inconveniently small.  However, if you increase it too far,
-Emacs could run out of memory trying to make the stack bigger.  */);
+Emacs could run out of memory trying to make the stack bigger.
+Note that this limit may be silently increased by the debugger
+if `debug-on-error' or `debug-on-quit' is set.  */);
 
   DEFVAR_INT ("max-lisp-eval-depth", max_lisp_eval_depth,
 	      doc: /* Limit on depth in `eval', `apply' and `funcall' before error.