aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-02-20 15:09:58 -0800
committerPaul Eggert2012-02-20 15:09:58 -0800
commit310f5bd4294ec3624b425e2c27da6fc730d0e928 (patch)
treeb1989e75f50a4c50c9b5fe34b698c93c2abec7ff /src
parent132b9726f60888f990e6174ce430769eb9dda986 (diff)
downloademacs-310f5bd4294ec3624b425e2c27da6fc730d0e928.tar.gz
emacs-310f5bd4294ec3624b425e2c27da6fc730d0e928.zip
Fix crash due to non-contiguous EMACS_INT (Bug#10780).
* lisp.h (VALBITS): Move definition up, so that USE_LSB_TAG can use it. (USE_LSB_TAG): Do not define if UINTPTR_MAX >> VALBITS == 0. It's useless in that case, and it can cause problems on hosts that allocate halves of EMACS_INT values separately. Reported by Dan Horák. Diagnosed by Andreas Schwab in <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10780#30>. * mem-limits.h (EXCEEDS_LISP_PTR): Define to 0 on hosts where UINTPTR_MAX >> VALBITS == 0. This is required by the above change; it avoids undefined behavior on hosts where shifting right by more than the word width has undefined behavior.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/lisp.h19
-rw-r--r--src/mem-limits.h2
3 files changed, 28 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3716aee7d69..911799b2bd2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
12012-02-20 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix crash due to non-contiguous EMACS_INT (Bug#10780).
4 * lisp.h (VALBITS): Move definition up, so that USE_LSB_TAG can use it.
5 (USE_LSB_TAG): Do not define if UINTPTR_MAX >> VALBITS == 0.
6 It's useless in that case, and it can cause problems on hosts
7 that allocate halves of EMACS_INT values separately.
8 Reported by Dan Horák. Diagnosed by Andreas Schwab in
9 <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10780#30>.
10 * mem-limits.h (EXCEEDS_LISP_PTR): Define to 0 on hosts where
11 UINTPTR_MAX >> VALBITS == 0. This is required by the above change;
12 it avoids undefined behavior on hosts where shifting right by more
13 than the word width has undefined behavior.
14
12012-02-19 Chong Yidong <cyd@gnu.org> 152012-02-19 Chong Yidong <cyd@gnu.org>
2 16
3 * fileio.c (Ffile_name_directory, Ffile_name_nondirectory) 17 * fileio.c (Ffile_name_directory, Ffile_name_nondirectory)
diff --git a/src/lisp.h b/src/lisp.h
index 366d24a737d..8bfd7071e5f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -168,6 +168,10 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
168#define GCTYPEBITS 3 168#define GCTYPEBITS 3
169#endif 169#endif
170 170
171#ifndef VALBITS
172#define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)
173#endif
174
171#ifndef NO_DECL_ALIGN 175#ifndef NO_DECL_ALIGN
172# ifndef DECL_ALIGN 176# ifndef DECL_ALIGN
173# if HAVE_ATTRIBUTE_ALIGNED 177# if HAVE_ATTRIBUTE_ALIGNED
@@ -191,7 +195,15 @@ extern int suppress_checking EXTERNALLY_VISIBLE;
191 || defined DARWIN_OS || defined __sun) 195 || defined DARWIN_OS || defined __sun)
192/* We also need to be able to specify mult-of-8 alignment on static vars. */ 196/* We also need to be able to specify mult-of-8 alignment on static vars. */
193# if defined DECL_ALIGN 197# if defined DECL_ALIGN
194# define USE_LSB_TAG 198/* mark_maybe_object assumes that EMACS_INT values are contiguous,
199 but this is not true on some hosts where EMACS_INT is wider than a pointer,
200 as they may allocate the halves of an EMACS_INT separately.
201 On these hosts USE_LSB_TAG is not needed because the top bits of an
202 EMACS_INT are unused, so define USE_LSB_TAG only on hosts where it
203 might be useful. */
204# if UINTPTR_MAX >> VALBITS != 0
205# define USE_LSB_TAG
206# endif
195# endif 207# endif
196#endif 208#endif
197 209
@@ -309,11 +321,6 @@ enum Lisp_Fwd_Type
309 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */ 321 Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */
310 }; 322 };
311 323
312/* These values are overridden by the m- file on some machines. */
313#ifndef VALBITS
314#define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)
315#endif
316
317#ifdef USE_LISP_UNION_TYPE 324#ifdef USE_LISP_UNION_TYPE
318 325
319#ifndef WORDS_BIGENDIAN 326#ifndef WORDS_BIGENDIAN
diff --git a/src/mem-limits.h b/src/mem-limits.h
index 472e591b38d..244592a9768 100644
--- a/src/mem-limits.h
+++ b/src/mem-limits.h
@@ -34,7 +34,7 @@ extern int etext;
34#endif 34#endif
35 35
36extern char *start_of_data (void); 36extern char *start_of_data (void);
37#if defined USE_LSB_TAG 37#if defined USE_LSB_TAG || UINTPTR_MAX >> VALBITS == 0
38#define EXCEEDS_LISP_PTR(ptr) 0 38#define EXCEEDS_LISP_PTR(ptr) 0
39#elif defined DATA_SEG_BITS 39#elif defined DATA_SEG_BITS
40#define EXCEEDS_LISP_PTR(ptr) \ 40#define EXCEEDS_LISP_PTR(ptr) \