emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r109420: Improve fix for macroexp cra


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109420: Improve fix for macroexp crash with debugging.
Date: Fri, 03 Aug 2012 13:55:27 -0700
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109420
fixes bug: http://debbugs.gnu.org/12118
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Fri 2012-08-03 13:55:27 -0700
message:
  Improve fix for macroexp crash with debugging.
  
  * 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.
modified:
  src/ChangeLog
  src/lisp.h
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-08-03 10:23:30 +0000
+++ b/src/ChangeLog     2012-08-03 20:55:27 +0000
@@ -1,3 +1,15 @@
+2012-08-03  Paul Eggert  <address@hidden>
+
+       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  <address@hidden>
 
        Support symlinks on latest versions of MS-Windows.

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-08-02 20:59:49 +0000
+++ b/src/lisp.h        2012-08-03 20:55:27 +0000
@@ -608,7 +608,7 @@
 /* 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.  */
@@ -2356,33 +2356,41 @@
 }
 
 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.  */


reply via email to

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