tags 451496 + fixed-upstream patch
thanks

Max Kellermann <[EMAIL PROTECTED]> writes:

> I was trying to save a file which is owned by my user, but the parent
> directory is read-only root:root, and an old backup file (tilde
> suffix) already existed, also read-only root:root.
>
> Emacs now consumed 100% CPU; an strace showed the following:
>
>   lstat("/usr/src/debian/build/icu-3.6/debian/changelog~", 
> {st_mode=S_IFREG|0644, st_size=9902, ...}) = 0
>   stat("/usr/src/debian/build/icu-3.6/debian/changelog~", 
> {st_mode=S_IFREG|0644, st_size=9902, ...}) = 0
>   unlink("/usr/src/debian/build/icu-3.6/debian/changelog~") = -1 EACCES 
> (Permission denied)
>   stat("/usr/src/debian/build/icu-3.6/debian/changelog~", 
> {st_mode=S_IFREG|0644, st_size=9902, ...}) = 0
>   lstat("/usr/src/debian/build/icu-3.6/debian/changelog~", 
> {st_mode=S_IFREG|0644, st_size=9902, ...}) = 0
>   stat("/usr/src/debian/build/icu-3.6/debian/changelog~", 
> {st_mode=S_IFREG|0644, st_size=9902, ...}) = 0

This bug has been fixed upstream, here is a patch for the function
backup-buffer-copy from the Emacs 22.2 release branch:

--- files.el~   2007-11-03 09:46:24.000000000 +0100
+++ files.el    2007-11-16 17:05:37.000000000 +0100
@@ -3117,17 +3117,22 @@
          ;; loosen them later, whereas it's impossible to close the
          ;; time-window of loose permissions otherwise.
          (set-default-file-modes ?\700)
-         (while (condition-case ()
-                    (progn
-                      (condition-case nil
-                          (delete-file to-name)
-                        (file-error nil))
-                      (copy-file from-name to-name nil t)
-                      nil)
-                  (file-already-exists t))
-           ;; The file was somehow created by someone else between
-           ;; `delete-file' and `copy-file', so let's try again.
-           nil))
+         (when (condition-case nil
+                   ;; Try to overwrite old backup first.
+                   (copy-file from-name to-name t t)
+                 (error t))
+           (while (condition-case nil
+                      (progn
+                        (when (file-exists-p to-name)
+                          (delete-file to-name))
+                        (copy-file from-name to-name nil t)
+                        nil)
+                    (file-already-exists t))
+             ;; The file was somehow created by someone else between
+             ;; `delete-file' and `copy-file', so let's try again.
+             ;; rms says "I think there is also a possible race
+             ;; condition for making backup files" (emacs-devel 20070821).
+             nil)))
       ;; Reset the umask.
       (set-default-file-modes umask)))
   (and modes


In the meantime, a workaround is to press C-g to get out of the
endless loop and then to save the file with M-0 C-x C-s (that does not
try to make a backup).

Cheers,
       Sven



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to