emacs-devel
[Top][All Lists]
Advanced

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

Re: wide-int crash [was Re: [PATCH updated] Support for filesystem watch


From: Paul Eggert
Subject: Re: wide-int crash [was Re: [PATCH updated] Support for filesystem watching (inotify)]
Date: Wed, 06 Jul 2011 15:31:27 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Thunderbird/3.1.10

On 07/06/11 12:14, Glenn Morris wrote:

> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8884

Thanks for the heads-up.  Although the nearby code has a portability bug
regardless of whether --with-wide-int is used, --with-wide-int
is more likely to tickle the bug.  The bug could well explain the
symptoms Peter observed.

I committed the following patch into the trunk.  Peter,
can you please check whether it solves your problem?  If not,
can you please compile with -g and without -O, and use GDB to report
the following values at the point of the crash: buffer_local_flags,
idx, offset, sizeof (struct buffer).  Thanks.

=== modified file 'src/ChangeLog'
--- src/ChangeLog       2011-07-05 09:51:56 +0000
+++ src/ChangeLog       2011-07-06 22:22:32 +0000
@@ -1,3 +1,15 @@
+2011-07-06  Paul Eggert  <address@hidden>
+
+       Remove unportable assumption about struct layout (Bug#8884).
+       * alloc.c (mark_buffer):
+       * buffer.c (reset_buffer_local_variables, Fbuffer_local_variables)
+       (clone_per_buffer_values): Don't assume that
+       sizeof (struct buffer) is a multiple of sizeof (Lisp_Object).
+       This isn't true in general, and it's particularly not true
+       if Emacs is configured with --with-wide-int.
+       * buffer.h (FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER):
+       New macros, used in the buffer.c change.
+
 2011-07-05  Jan Djärv  <address@hidden>
 
        * xsettings.c: Use both GConf and GSettings if both are available.

=== modified file 'src/alloc.c'
--- src/alloc.c 2011-06-24 21:25:22 +0000
+++ src/alloc.c 2011-07-06 22:22:32 +0000
@@ -5619,7 +5619,8 @@
   /* buffer-local Lisp variables start at `undo_list',
      tho only the ones from `name' on are GC'd normally.  */
   for (ptr = &buffer->BUFFER_INTERNAL_FIELD (name);
-       (char *)ptr < (char *)buffer + sizeof (struct buffer);
+       ptr <= &PER_BUFFER_VALUE (buffer,
+                                PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER));
        ptr++)
     mark_object (*ptr);
 

=== modified file 'src/buffer.c'
--- src/buffer.c        2011-07-04 15:32:22 +0000
+++ src/buffer.c        2011-07-06 22:22:32 +0000
@@ -471,8 +471,8 @@
 
   /* buffer-local Lisp variables start at `undo_list',
      tho only the ones from `name' on are GC'd normally.  */
-  for (offset = PER_BUFFER_VAR_OFFSET (undo_list);
-       offset < sizeof *to;
+  for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER);
+       offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER);
        offset += sizeof (Lisp_Object))
     {
       Lisp_Object obj;
@@ -830,8 +830,8 @@
 
   /* buffer-local Lisp variables start at `undo_list',
      tho only the ones from `name' on are GC'd normally.  */
-  for (offset = PER_BUFFER_VAR_OFFSET (undo_list);
-       offset < sizeof *b;
+  for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER);
+       offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER);
        offset += sizeof (Lisp_Object))
     {
       int idx = PER_BUFFER_IDX (offset);
@@ -1055,8 +1055,8 @@
 
     /* buffer-local Lisp variables start at `undo_list',
        tho only the ones from `name' on are GC'd normally.  */
-    for (offset = PER_BUFFER_VAR_OFFSET (undo_list);
-        offset < sizeof (struct buffer);
+    for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER);
+        offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER);
         /* sizeof EMACS_INT == sizeof Lisp_Object */
         offset += (sizeof (EMACS_INT)))
       {

=== modified file 'src/buffer.h'
--- src/buffer.h        2011-06-21 21:32:10 +0000
+++ src/buffer.h        2011-07-06 21:53:56 +0000
@@ -612,6 +612,7 @@
   /* Everything from here down must be a Lisp_Object.  */
   /* buffer-local Lisp variables start at `undo_list',
      tho only the ones from `name' on are GC'd normally.  */
+  #define FIRST_FIELD_PER_BUFFER undo_list
 
   /* Changes in the buffer are recorded here for undo.
      t means don't record anything.
@@ -846,6 +847,9 @@
      t means to use hollow box cursor.
      See `cursor-type' for other values.  */
   Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows);
+
+  /* This must be the last field in the above list.  */
+  #define LAST_FIELD_PER_BUFFER cursor_in_non_selected_windows
 };
 
 




reply via email to

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