From: Paul Eggert Date: Fri, 3 Aug 2012 20:55:27 +0000 (-0700) Subject: Improve fix for macroexp crash with debugging. X-Git-Tag: emacs-24.2.90~869 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8834c57aab03fb7ea9d92f9e995844ff7ce64b7b;p=emacs.git 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 . (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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 3ba80f69749..4aa0dcb022e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2012-08-03 Paul Eggert + + 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 . + (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 Support symlinks on latest versions of MS-Windows. diff --git a/src/lisp.h b/src/lisp.h index 3d00f4dde78..e77b76005cd 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -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. */