unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Fabrice Popineau" <fabrice.popineau@supelec.fr>
To: emacs-devel@gnu.org
Subject: patch to fileio.c
Date: Sun, 26 Oct 2008 16:15:28 +0100	[thread overview]
Message-ID: <ge21iv$ivt$1@ger.gmane.org> (raw)

Hi,

You should consider adding the following patch. As I reported earlier, the 
fd file descriptor may be
closed twice in insert-file-contents. It happens every time a file is 
visited and this same file is modified
outside emacs. In this case, you can ask to visit the file again (or emacs 
will ask you if you try to save it)

"File foobar.txt changed on disk. Reread from disk? (yes or no)"

The fd file descriptor in this case is closed  by emacs_close() at line 3654
and by close_file_unwind() registered at line 3233. When emacs_close(fd) is 
reached, the unwind_protect
registered function should be removed. Unfortunately, in the mean time other 
stuff has
been put in the unwind_protect stack, so you can't just decrement the 
pointer. It can be done
when the handled: label is reached. Hence the flag in my patch.

There was a previous patch may be related to the same problem, but not 
fixing it:
2008-09-14  Kenichi Handa  <handa@m17n.org>

 * fileio.c (Finsert_file_contents): Delete incorrect decrement of
 specpdl_ptr.

Best regards,

Fabrice

--- \Mirror\emacs\src\fileio.c  2008-10-16 21:30:49.000000000 +0200
+++ fileio.c    2008-10-26 10:39:11.000000000 +0100
@@ -3141,6 +3141,7 @@
   int read_quit = 0;
   Lisp_Object old_Vdeactivate_mark = Vdeactivate_mark;
   int we_locked_file = 0;
+  int should_remove_unwind_protect = 0;

   if (current_buffer->base_buffer && ! NILP (visit))
     error ("Cannot do file visiting in an indirect buffer");
@@ -3650,8 +3651,10 @@
          if (coding.carryover_bytes > 0)
            bcopy (coding.carryover, read_buf, unprocessed);
        }
+
       UNGCPRO;
       emacs_close (fd);
+      should_remove_unwind_protect = 1;

       /* At this point, HOW_MUCH should equal TOTAL, or should be <= 0
         if we couldn't read the file.  */
@@ -4033,6 +4036,9 @@
 #endif

  handled:
+#if 1
+  if (should_remove_unwind_protect) specpdl_ptr--;
+#endif

   if (!NILP (visit))
     {
 






             reply	other threads:[~2008-10-26 15:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-26 15:15 Fabrice Popineau [this message]
2008-11-04 17:20 ` patch to fileio.c Chong Yidong
2008-11-07  0:17   ` Fabrice Popineau
2008-11-13 15:43     ` Chong Yidong
2008-11-14 19:01       ` Eli Zaretskii
2008-11-14 21:11 ` Chong Yidong
2008-11-14 21:16   ` Chong Yidong
2008-11-14 22:28     ` Juanma Barranquero

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='ge21iv$ivt$1@ger.gmane.org' \
    --to=fabrice.popineau@supelec.fr \
    --cc=emacs-devel@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).