]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve fix for macroexp crash with debugging.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 3 Aug 2012 20:55:27 +0000 (13:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 3 Aug 2012 20:55:27 +0000 (13:55 -0700)
* lisp.h (ASET) [ENABLE_CHECKING]: Pay attention to
ARRAY_MARK_FLAG when checking subscripts, because ASET is
not supposed to be invoked from the garbage collector.
See Andreas Schwab in <http://bugs.gnu.org/12118#25>.
(gc_aset): New function, which is like ASET but can be
used in the garbage collector.
(set_hash_key, set_hash_value, set_hash_next, set_hash_hash)
(set_hash_index): Use it instead of ASET.

src/ChangeLog
src/lisp.h

index 3ba80f69749fea935e80279371f9d1530d6eed49..4aa0dcb022ece5176851183c16d35a6bcd6b8b0c 100644 (file)
@@ -1,3 +1,15 @@
+2012-08-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Improve fix for macroexp crash with debugging (Bug#12118).
+       * lisp.h (ASET) [ENABLE_CHECKING]: Pay attention to
+       ARRAY_MARK_FLAG when checking subscripts, because ASET is
+       not supposed to be invoked from the garbage collector.
+       See Andreas Schwab in <http://bugs.gnu.org/12118#25>.
+       (gc_aset): New function, which is like ASET but can be
+       used in the garbage collector.
+       (set_hash_key, set_hash_value, set_hash_next, set_hash_hash)
+       (set_hash_index): Use it instead of ASET.
+
 2012-08-03  Eli Zaretskii  <eliz@gnu.org>
 
        Support symlinks on latest versions of MS-Windows.
index 3d00f4dde78b385cc50d5c1ac9535266e4b6c935..e77b76005cdead78be24ada43ae223a8a2f6c348 100644 (file)
@@ -608,7 +608,7 @@ clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
 /* The IDX==IDX tries to detect when the macro argument is side-effecting.  */
 #define ASET(ARRAY, IDX, VAL)  \
   (eassert ((IDX) == (IDX)),                           \
-   eassert ((IDX) >= 0 && (IDX) < (ASIZE (ARRAY) & ~ARRAY_MARK_FLAG)), \
+   eassert ((IDX) >= 0 && (IDX) < ASIZE (ARRAY)),      \
    XVECTOR (ARRAY)->contents[IDX] = (VAL))
 
 /* Convenience macros for dealing with Lisp strings.  */
@@ -2355,34 +2355,42 @@ aref_addr (Lisp_Object array, ptrdiff_t idx)
   return & XVECTOR (array)->contents[idx];
 }
 
+LISP_INLINE void
+gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
+{
+  /* Like ASET, but also can be used in the garbage collector.  */
+  eassert (0 <= idx && idx < (ASIZE (array) & ~ARRAY_MARK_FLAG));
+  XVECTOR (array)->contents[idx] = val;
+}
+
 LISP_INLINE void
 set_hash_key (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
 {
-  ASET (h->key_and_value, 2 * idx, val);
+  gc_aset (h->key_and_value, 2 * idx, val);
 }
 
 LISP_INLINE void
 set_hash_value (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
 {
-  ASET (h->key_and_value, 2 * idx + 1, val);
+  gc_aset (h->key_and_value, 2 * idx + 1, val);
 }
 
 LISP_INLINE void
 set_hash_next (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
 {
-  ASET (h->next, idx, val);
+  gc_aset (h->next, idx, val);
 }
 
 LISP_INLINE void
 set_hash_hash (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
 {
-  ASET (h->hash, idx, val);
+  gc_aset (h->hash, idx, val);
 }
 
 LISP_INLINE void
 set_hash_index (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
 {
-  ASET (h->index, idx, val);
+  gc_aset (h->index, idx, val);
 }
 
 /* Defined in data.c.  */