Subject: bug#12007: 24.1.50; Crash in auto-revert-handler

From: Dmitry Antipov <[email-masked]>
Date: Wed, 25 Jul 2012 06:37:11 +0400

On 07/25/2012 04:39 AM, Christoph Scholtes wrote:

> bzr r109196 still crashes after sitting for a while.

Hm... that crash becomes annoying (although I can't reproduce it). Try this.

Dmitry
=== modified file 'src/buffer.c'
--- src/buffer.c	2012-07-24 06:45:44 +0000
+++ src/buffer.c	2012-07-25 02:29:34 +0000
@@ -1560,14 +1560,6 @@
   if (EQ (buffer, XWINDOW (minibuf_window)->buffer))
     return Qnil;
 
-  /* Notify our base buffer that we don't share the text anymore.  */
-  if (b->base_buffer)
-    {
-      eassert (b->indirections == -1);
-      b->base_buffer->indirections--;
-      eassert (b->base_buffer->indirections >= 0);
-    }
-
   /* When we kill an ordinary buffer which shares it's buffer text
      with indirect buffer(s), we must kill indirect buffer(s) too.
      We do it at this stage so nothing terrible happens if they
@@ -1708,7 +1700,15 @@
   BVAR (b, name) = Qnil;
 
   BLOCK_INPUT;
-  if (! b->base_buffer)
+  /* Notify our base buffer that we don't share the text anymore.  */
+  if (b->base_buffer)
+    {
+      eassert (b->indirections == -1);
+      b->base_buffer->indirections--;
+      eassert (b->base_buffer->indirections >= 0);
+    }
+  else
+    /* No one shares our buffer text, can free it.  */
     free_buffer_text (b);
 
   if (b->newline_cache)
@@ -4897,6 +4897,9 @@
   /* Prevent GC from getting confused.  */
   buffer_defaults.text = &buffer_defaults.own_text;
   buffer_local_symbols.text = &buffer_local_symbols.own_text;
+  /* No one will share the text with these buffers, but let's play it safe.  */
+  buffer_defaults.indirections = 0;
+  buffer_local_symbols.indirections = 0;
   BUF_INTERVALS (&buffer_defaults) = 0;
   BUF_INTERVALS (&buffer_local_symbols) = 0;
   XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize);