emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r107358: Fix crash due to non-contigu


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107358: Fix crash due to non-contiguous EMACS_INT (Bug#10780).
Date: Mon, 20 Feb 2012 15:09:58 -0800
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107358
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Mon 2012-02-20 15:09:58 -0800
message:
  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.
modified:
  src/ChangeLog
  src/lisp.h
  src/mem-limits.h
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-02-19 09:58:23 +0000
+++ b/src/ChangeLog     2012-02-20 23:09:58 +0000
@@ -1,3 +1,17 @@
+2012-02-20  Paul Eggert  <address@hidden>
+
+       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.
+
 2012-02-19  Chong Yidong  <address@hidden>
 
        * fileio.c (Ffile_name_directory, Ffile_name_nondirectory)

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-01-19 07:21:25 +0000
+++ b/src/lisp.h        2012-02-20 23:09:58 +0000
@@ -168,6 +168,10 @@
 #define GCTYPEBITS 3
 #endif
 
+#ifndef VALBITS
+#define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)
+#endif
+
 #ifndef NO_DECL_ALIGN
 # ifndef DECL_ALIGN
 #  if HAVE_ATTRIBUTE_ALIGNED
@@ -191,7 +195,15 @@
      || defined DARWIN_OS || defined __sun)
 /* We also need to be able to specify mult-of-8 alignment on static vars.  */
 # if defined DECL_ALIGN
-#  define USE_LSB_TAG
+/* mark_maybe_object assumes that EMACS_INT values are contiguous,
+   but this is not true on some hosts where EMACS_INT is wider than a pointer,
+   as they may allocate the halves of an EMACS_INT separately.
+   On these hosts USE_LSB_TAG is not needed because the top bits of an
+   EMACS_INT are unused, so define USE_LSB_TAG only on hosts where it
+   might be useful.  */
+#  if UINTPTR_MAX >> VALBITS != 0
+#   define USE_LSB_TAG
+#  endif
 # endif
 #endif
 
@@ -309,11 +321,6 @@
     Lisp_Fwd_Kboard_Obj,       /* Fwd to a Lisp_Object field of kboards.  */
   };
 
-/* These values are overridden by the m- file on some machines.  */
-#ifndef VALBITS
-#define VALBITS (BITS_PER_EMACS_INT - GCTYPEBITS)
-#endif
-
 #ifdef USE_LISP_UNION_TYPE
 
 #ifndef WORDS_BIGENDIAN

=== modified file 'src/mem-limits.h'
--- a/src/mem-limits.h  2012-01-19 07:21:25 +0000
+++ b/src/mem-limits.h  2012-02-20 23:09:58 +0000
@@ -34,7 +34,7 @@
 #endif
 
 extern char *start_of_data (void);
-#if defined USE_LSB_TAG
+#if defined USE_LSB_TAG || UINTPTR_MAX >> VALBITS == 0
 #define EXCEEDS_LISP_PTR(ptr) 0
 #elif defined DATA_SEG_BITS
 #define EXCEEDS_LISP_PTR(ptr) \


reply via email to

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