Subject: bug#20417: 25.0.50; frequent crashes with global-auto-revert-mode

From: Paul Eggert <[email-masked]>
Date: Sat, 25 Apr 2015 18:58:14 -0700

> I am not sure whether Emacs can work around this or not.

I don't see an easy workaround.

> Perhaps one approach would be to not use the glib file-polling code.

That sounds like it may be the best way forward, at least in the short run.  If 
you configure --with-file-notification=inotify does the problem go away for you? 
  That is, does the attached patch work for you?
>From fc809b12a049d8b1af69299eb05cf13c3ecf6291 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sat, 25 Apr 2015 18:55:55 -0700
Subject: [PATCH] Use gfile notification only on request

Unfortunately gfile notification seems to have serious bugs; see
https://bugzilla.gnome.org/show_bug.cgi?id=739424
They can make Emacs crash (Bug#20417).
We don't know of any workaround.  For now, enable gfile
notification only if Emacs is explicitly configured that way.
* configure.ac (NOTIFY_OBJ): Use gfilenotify.o only upon request.
---
 configure.ac | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index d2f21ee..d9df7ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -362,7 +362,7 @@ AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
     * ) AC_MSG_ERROR(['--with-file-notification=$withval' is invalid;
 this option's value should be 'yes', 'no', 'gfile', 'inotify' or 'w32'.
 'yes' is a synonym for 'w32' on MS-Windows, for 'no' on Nextstep,
-otherwise for the first of 'gfile' or 'inotify' that is usable.])
+otherwise for 'inotify' if usable.])
     ;;
    esac
    with_file_notification=$val
@@ -2696,8 +2696,7 @@ dnl MS Windows native file monitor is available for mingw32 only.
 case $with_file_notification,$opsys in
   w32,cygwin)
     AC_MSG_ERROR(['--with-file-notification=w32' was specified, but
-    this is only supported on MS-Windows native and MinGW32 builds.
-    Consider using gfile instead.])
+    this is supported only on MS-Windows native and MinGW32 builds.])
     ;;
   w32,* | yes,mingw32)
     AC_CHECK_HEADER(windows.h)
@@ -2710,11 +2709,12 @@ esac
 
 dnl g_file_monitor exists since glib 2.18.  G_FILE_MONITOR_EVENT_MOVED
 dnl has been added in glib 2.24.  It has been tested under
-dnl GNU/Linux only.  We take precedence over inotify, but this makes
-dnl only sense when glib has been compiled with inotify support.  How
+dnl GNU/Linux only.  As of April 2015 it exposes serious glib bugs
+dnl (see Bug#20417) so it is enabled only on explicit request.  Also,
+dnl it makes sense only when glib has been compiled with inotify support.  How
 dnl to check?
 case $with_file_notification,$NOTIFY_OBJ in
-  gfile, | yes,)
+  gfile, )
     EMACS_CHECK_MODULES([GFILENOTIFY], [gio-2.0 >= 2.24])
     if test "$HAVE_GFILENOTIFY" = "yes"; then
        AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
@@ -2723,7 +2723,7 @@ case $with_file_notification,$NOTIFY_OBJ in
     fi ;;
 esac
 
-dnl inotify is only available on GNU/Linux.
+dnl inotify is available only on GNU/Linux.
 case $with_file_notification,$NOTIFY_OBJ in
   inotify, | yes,)
     AC_CHECK_HEADER(sys/inotify.h)
-- 
2.1.0