unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Glenn Morris <rgm@gnu.org>
Cc: 8884@debbugs.gnu.org, Peter Dyballa <Peter_Dyballa@Freenet.DE>,
	emacs-devel@gnu.org
Subject: Re: wide-int crash [was Re: [PATCH updated] Support for filesystem watching (inotify)]
Date: Wed, 06 Jul 2011 15:31:27 -0700	[thread overview]
Message-ID: <4E14E23F.4070507@cs.ucla.edu> (raw)
In-Reply-To: <2v8vsbte5m.fsf@fencepost.gnu.org>

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  <eggert@cs.ucla.edu>
+
+	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  <jan.h.d@swipnet.se>
 
 	* 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
 };
 
 \f




  reply	other threads:[~2011-07-06 22:31 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 22:34 [PATCH] Support for filesystem watching (inotify) Rüdiger Sonderfeld
2011-06-04  8:52 ` joakim
2011-06-04 16:40   ` Rüdiger Sonderfeld
2011-06-04 10:43 ` Jan Djärv
2011-06-04 23:36   ` [PATCH update2] " Rüdiger Sonderfeld
2011-06-05  5:45     ` Eli Zaretskii
2011-06-05  9:48       ` [PATCH update3] " Rüdiger Sonderfeld
2011-06-05  7:48     ` [PATCH update2] " Jan Djärv
2011-06-05  7:54     ` Andreas Schwab
2011-06-05  9:49       ` Rüdiger Sonderfeld
2011-06-05 15:59         ` John Yates
2011-06-05 16:14           ` Rüdiger Sonderfeld
2011-06-05 16:58             ` Eli Zaretskii
2011-06-06 18:56               ` Rüdiger Sonderfeld
2011-06-06 19:57                 ` Eli Zaretskii
2011-06-04 11:30 ` [PATCH] " Eli Zaretskii
2011-06-04 17:13   ` [PATCH updated] " Rüdiger Sonderfeld
2011-06-04 19:15     ` Eli Zaretskii
2011-06-04 20:10     ` Thien-Thi Nguyen
2011-06-04 23:43       ` Rüdiger Sonderfeld
2011-06-05  2:15         ` Thien-Thi Nguyen
2011-06-05  9:22           ` Štěpán Němec
2011-06-15 20:53             ` Johan Bockgård
2011-06-16  8:52               ` Inlined cl functions -- how to learn about them Štěpán Němec
2011-06-06 15:21       ` [PATCH updated] Support for filesystem watching (inotify) Stefan Monnier
2011-06-06 16:25         ` Rüdiger Sonderfeld
2011-06-06 17:11           ` Stefan Monnier
2011-06-06 20:16             ` Ted Zlatanov
2011-06-07 14:42               ` Stefan Monnier
2011-06-07 16:46                 ` Ted Zlatanov
2011-06-07 18:06                   ` Stefan Monnier
2011-06-07 18:26                     ` Ted Zlatanov
2011-06-24  0:50             ` Rüdiger Sonderfeld
2011-06-24 10:19               ` Ted Zlatanov
2011-06-24 12:18                 ` Ted Zlatanov
2011-07-06 13:36               ` Stefan Monnier
2011-07-06 15:54                 ` Paul Eggert
2011-07-06 18:30                   ` Stefan Monnier
2011-07-06 20:39                     ` Paul Eggert
2011-07-06 19:14                   ` wide-int crash [was Re: [PATCH updated] Support for filesystem watching (inotify)] Glenn Morris
2011-07-06 22:31                     ` Paul Eggert [this message]
2011-07-07 19:43               ` [PATCH updated] Support for filesystem watching (inotify) Stefan Monnier
2012-09-28 13:06                 ` [PATCH] Added basic file system watching support Rüdiger Sonderfeld
2012-09-28 14:13                   ` Stefan Monnier
2012-09-28 16:27                     ` Rüdiger Sonderfeld
2012-10-01  4:38                       ` Stefan Monnier
2012-10-01  7:24                         ` Eli Zaretskii
2012-10-01 14:09                         ` [PATCH] Added inotify support Rüdiger Sonderfeld
2012-10-01 16:27                           ` Stefan Monnier
2012-10-02 21:28                           ` Eli Zaretskii
2012-10-02 23:46                             ` Óscar Fuentes
2012-10-03  2:10                               ` Stefan Monnier
2012-10-03  3:54                                 ` Eli Zaretskii
2012-10-03 12:46                                   ` Stefan Monnier
2012-10-03 18:34                                     ` Eli Zaretskii
2012-10-03 18:47                                       ` Stefan Monnier
2012-10-03 19:08                                         ` Eli Zaretskii
2012-10-03 20:59                                           ` Stefan Monnier
2012-10-12 13:54                                             ` Eli Zaretskii
2012-10-14 14:55                                               ` Eli Zaretskii
2012-10-03 19:33                                       ` Óscar Fuentes
2012-10-05  7:40                                         ` Eli Zaretskii
2012-10-05 13:07                                           ` Óscar Fuentes
2012-10-05 15:19                                             ` Eli Zaretskii
2012-10-05 16:55                                 ` Nix
2012-10-05 17:15                                   ` Eli Zaretskii
2012-10-05 17:46                                     ` Nix
2012-10-05 18:22                                   ` Stefan Monnier
2012-10-05 18:30                                     ` Óscar Fuentes
2012-10-06 16:39                                     ` Nix
2012-10-06 17:01                                       ` Stefan Monnier
2012-10-06 18:51                                         ` Nix
2012-10-06 21:26                                           ` Stefan Monnier
2012-10-06 21:28                                             ` Nix
2012-10-07  7:38                                               ` Achim Gratz
2012-10-07 13:58                                                 ` Stefan Monnier
2012-10-07 14:54                                                   ` Achim Gratz
2012-10-07  8:24                                               ` Stephen J. Turnbull
2012-10-07 14:00                                                 ` Stefan Monnier
2012-10-07 14:28                                                   ` Óscar Fuentes
2012-10-07 14:38                                                     ` Stefan Monnier
2012-10-08  7:07                                                   ` Stephen J. Turnbull
2012-10-08  8:06                                                     ` Eli Zaretskii
2012-10-14 15:52                                           ` Jim Meyering
2012-10-06  7:04                                   ` Stephen J. Turnbull
2012-10-06  7:23                                     ` Andreas Schwab
2012-10-06 16:41                                       ` Nix
2012-10-07  8:09                                         ` Stephen J. Turnbull
2012-10-07 14:08                                           ` Stefan Monnier
2012-10-03  3:57                               ` Eli Zaretskii
2012-12-02 20:08                           ` Eli Zaretskii
2012-12-03 17:18                             ` Stefan Monnier
2012-12-10 14:16                               ` Eli Zaretskii
2012-12-10 14:47                                 ` Stefan Monnier
2012-12-10 11:52                           ` Eli Zaretskii
2012-12-10 12:11                             ` Rüdiger Sonderfeld
2012-12-11  7:43                             ` Michael Albinus
2012-12-11  8:20                               ` Eli Zaretskii
2012-12-11 16:36                                 ` Michael Albinus
2012-12-11 16:46                                   ` Rüdiger Sonderfeld
2012-12-11 20:17                                     ` Michael Albinus
2012-12-11  7:54                         ` [PATCH] Added basic file system watching support Michael Albinus
2012-12-11  8:12                           ` Eli Zaretskii
2012-12-11  8:19                             ` Michael Albinus
2012-12-11  8:29                               ` Eli Zaretskii
2012-12-11  8:44                                 ` Michael Albinus
2012-12-11  9:39                                   ` Eli Zaretskii
2012-12-11 10:15                                     ` Eli Zaretskii
2012-12-11 10:38                                       ` Michael Albinus
2012-12-11 10:24                                     ` Michael Albinus
2012-12-11 12:51                                       ` Eli Zaretskii
2012-12-11 13:17                                         ` Michael Albinus
2012-12-11 13:23                                           ` Eli Zaretskii
2012-12-12  1:09                                         ` Leo
2012-12-12  3:57                                           ` Eli Zaretskii
2013-01-07 11:33                                     ` Michael Albinus
2013-01-07 15:57                                       ` Eli Zaretskii
2013-01-07 16:00                                         ` Michael Albinus
2013-01-07 20:26                                           ` Stefan Monnier
2013-01-08  7:44                                             ` Michael Albinus
2011-06-06 15:14     ` [PATCH updated] Support for filesystem watching (inotify) Stefan Monnier
2011-06-06 16:21       ` Rüdiger Sonderfeld
2012-09-18 11:50 ` [PATCH] " Leo
2012-09-26 12:15   ` Rüdiger Sonderfeld
2012-09-26 17:52     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E14E23F.4070507@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=8884@debbugs.gnu.org \
    --cc=Peter_Dyballa@Freenet.DE \
    --cc=emacs-devel@gnu.org \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).