Subject: Re: bug#14412: 24.3.50; emacs_backtrace.txt

From: Paul Eggert <[email-masked]>
Date: Sat, 26 Dec 2015 09:43:25 -0800

Eli, thanks for fixing that. There's parallel code in backtrace_eval_unrewind 
that presumably should be fixed in a similar way. Also, it's clearer to keep the 
FALLTHROUGH!! comment at the actual fallthrough point. I installed the attached 
additional patch to try to address these issues.
>From 60764d06b76ce39c2c902c302c29954945ed0e9c Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sat, 26 Dec 2015 09:30:22 -0800
Subject: [PATCH] Propagate Bug#14412 fix to backtrace_eval_unrewind
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/eval.c (unbind_to): Redo so that the FALLTHROUGH!! comment
becomes accurate again. This shouldn’t affect behavior.
(backtrace_eval_unrewind): Apply the recent unbind_to fix here, too.
---
 src/eval.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/eval.c b/src/eval.c
index 571681c..bd0cf68 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3196,15 +3196,12 @@ unbind_to (ptrdiff_t count, Lisp_Object value)
 	  { /* If variable has a trivial value (no forwarding), we can
 	       just set it.  No need to check for constant symbols here,
 	       since that was already done by specbind.  */
-	    Lisp_Object symbol = specpdl_symbol (specpdl_ptr);
-	    if (SYMBOLP (symbol))
+	    Lisp_Object sym = specpdl_symbol (specpdl_ptr);
+	    if (SYMBOLP (sym) && XSYMBOL (sym)->redirect == SYMBOL_PLAINVAL)
 	      {
-		struct Lisp_Symbol *sym = XSYMBOL (symbol);
-		if (sym->redirect == SYMBOL_PLAINVAL)
-		  {
-		    SET_SYMBOL_VAL (sym, specpdl_old_value (specpdl_ptr));
-		    break;
-		  }
+		SET_SYMBOL_VAL (XSYMBOL (sym),
+				specpdl_old_value (specpdl_ptr));
+		break;
 	      }
 	    else
 	      { /* FALLTHROUGH!!
@@ -3412,12 +3409,12 @@ backtrace_eval_unrewind (int distance)
 	  { /* If variable has a trivial value (no forwarding), we can
 	       just set it.  No need to check for constant symbols here,
 	       since that was already done by specbind.  */
-	    struct Lisp_Symbol *sym = XSYMBOL (specpdl_symbol (tmp));
-	    if (sym->redirect == SYMBOL_PLAINVAL)
+	    Lisp_Object sym = specpdl_symbol (tmp);
+	    if (SYMBOLP (sym) && XSYMBOL (sym)->redirect == SYMBOL_PLAINVAL)
 	      {
 		Lisp_Object old_value = specpdl_old_value (tmp);
-		set_specpdl_old_value (tmp, SYMBOL_VAL (sym));
-		SET_SYMBOL_VAL (sym, old_value);
+		set_specpdl_old_value (tmp, SYMBOL_VAL (XSYMBOL (sym)));
+		SET_SYMBOL_VAL (XSYMBOL (sym), old_value);
 		break;
 	      }
 	    else
-- 
2.5.0