emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114983: * src/eval.c (handlerlist_sentinel): New va


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r114983: * src/eval.c (handlerlist_sentinel): New variable.
Date: Tue, 05 Nov 2013 16:30:06 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114983
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15802
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Tue 2013-11-05 11:29:58 -0500
message:
  * src/eval.c (handlerlist_sentinel): New variable.
  (init_eval): Use it to ensure handlerlist is non-NULL.
  (unwind_to_catch): Make sure we never set handlerlist to NULL.
  (Fsignal): Adjust NULLness test of handlerlist.
  * src/lisp.h (PUSH_HANDLER): Assume handlerlist is non-NULL.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/eval.c                     eval.c-20091113204419-o5vbwnq5f7feedwu-237
  src/lisp.h                     lisp.h-20091113204419-o5vbwnq5f7feedwu-253
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-11-05 16:26:11 +0000
+++ b/src/ChangeLog     2013-11-05 16:29:58 +0000
@@ -1,3 +1,12 @@
+2013-11-05  Stefan Monnier  <address@hidden>
+
+       * eval.c (handlerlist_sentinel): New variable (bug#15802).
+       (init_eval): Use it to ensure handlerlist is non-NULL.
+       (unwind_to_catch): Make sure we never set handlerlist to NULL.
+       (Fsignal): Adjust NULLness test of handlerlist.
+
+       * lisp.h (PUSH_HANDLER): Assume handlerlist is non-NULL.
+
 2013-11-05  Eli Zaretskii  <address@hidden>
 
        * callproc.c (call_process): Call prepare_to_modify_buffer before

=== modified file 'src/eval.c'
--- a/src/eval.c        2013-10-29 14:46:23 +0000
+++ b/src/eval.c        2013-11-05 16:29:58 +0000
@@ -237,11 +237,22 @@
   Vrun_hooks = Qnil;
 }
 
+static struct handler handlerlist_sentinel;
+
 void
 init_eval (void)
 {
   specpdl_ptr = specpdl;
-  handlerlist = NULL;
+  { /* Put a dummy catcher at top-level so that handlerlist is never NULL.
+       This is important since handlerlist->nextfree holds the freelist
+       which would otherwise leak every time we unwind back to top-level.   */
+    struct handler *c;
+    handlerlist = handlerlist_sentinel.nextfree = &handlerlist_sentinel;
+    PUSH_HANDLER (c, Qunbound, CATCHER);
+    eassert (c == &handlerlist_sentinel);
+    handlerlist_sentinel.nextfree = NULL;
+    handlerlist_sentinel.next = NULL;
+  }
   Vquit_flag = Qnil;
   debug_on_next_call = 0;
   lisp_eval_depth = 0;
@@ -1129,6 +1140,8 @@
 {
   bool last_time;
 
+  eassert (catch->next);
+
   /* Save the value in the tag.  */
   catch->val = value;
 
@@ -1542,7 +1555,10 @@
     }
   else
     {
-      if (handlerlist != 0)
+      if (handlerlist != &handlerlist_sentinel)
+       /* FIXME: This will come right back here if there's no `top-level'
+          catcher.  A better solution would be to abort here, and instead
+          add a catch-all condition handler so we never come here.  */
        Fthrow (Qtop_level, Qt);
     }
 

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2013-11-05 07:11:24 +0000
+++ b/src/lisp.h        2013-11-05 16:29:58 +0000
@@ -2873,14 +2873,13 @@
 
 /* Fill in the components of c, and put it on the list.  */
 #define PUSH_HANDLER(c, tag_ch_val, handlertype)       \
-  if (handlerlist && handlerlist->nextfree)            \
+  if (handlerlist->nextfree)                           \
     (c) = handlerlist->nextfree;                       \
   else                                                 \
     {                                                  \
       (c) = xmalloc (sizeof (struct handler));         \
       (c)->nextfree = NULL;                            \
-      if (handlerlist)                                 \
-       handlerlist->nextfree = (c);                    \
+      handlerlist->nextfree = (c);                     \
     }                                                  \
   (c)->type = (handlertype);                           \
   (c)->tag_or_ch = (tag_ch_val);                       \


reply via email to

[Prev in Thread] Current Thread [Next in Thread]