]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug with clang + directory_files_internal + GC.
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 2 Aug 2014 22:58:09 +0000 (15:58 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 2 Aug 2014 22:58:09 +0000 (15:58 -0700)
* src/dired.c (directory_files_internal): Use a volatile variable
to prevent the compiler from optimizing away all copies of a local.
I wonder how many other GC-related bugs like this lurk elsewhere?

Fixes: debbugs:16986
src/ChangeLog
src/dired.c

index b85aee0d35a9482fdf1859805d672f3100d21db0..93c27a6e5659b70a7af1c0c85da227a232bb509a 100644 (file)
@@ -1,5 +1,10 @@
 2014-08-02  Paul Eggert  <eggert@cs.ucla.edu>
 
+       Fix bug with clang + directory_files_internal + GC (Bug#16986).
+       * dired.c (directory_files_internal): Use a volatile variable
+       to prevent the compiler from optimizing away all copies of a local.
+       I wonder how many other GC-related bugs like this lurk elsewhere?
+
        Avoid 100% CPU utilization on ssh session exit (Bug#17691).
        * xterm.h (struct x_display_info): New member 'connection'.
        * xterm.c (x_term_init, x_delete_terminal): Set and use it,
index 55b2f6658c7290d12e751ddca173ada2aab07556..c2db1f02782bceb9b5c8bf573cf8f78cf3b8ab2a 100644 (file)
@@ -150,6 +150,12 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
   Lisp_Object w32_save = Qnil;
 #endif
 
+  /* Don't let the compiler optimize away all copies of DIRECTORY,
+     which would break GC; see Bug#16986.  Although this is required
+     only in the common case where GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS,
+     it shouldn't break anything in the other cases.  */
+  Lisp_Object volatile directory_volatile = directory;
+
   /* Because of file name handlers, these functions might call
      Ffuncall, and cause a GC.  */
   list = encoded_directory = dirfilename = Qnil;
@@ -325,6 +331,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
     list = Fsort (Fnreverse (list),
                  attrs ? Qfile_attributes_lessp : Qstring_lessp);
 
+  (void) directory_volatile;
   RETURN_UNGCPRO (list);
 }