unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* patch to fileio.c
@ 2008-10-26 15:15 Fabrice Popineau
  2008-11-04 17:20 ` Chong Yidong
  2008-11-14 21:11 ` Chong Yidong
  0 siblings, 2 replies; 8+ messages in thread
From: Fabrice Popineau @ 2008-10-26 15:15 UTC (permalink / raw)
  To: emacs-devel

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))
     {
 






^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-11-14 22:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-26 15:15 patch to fileio.c Fabrice Popineau
2008-11-04 17:20 ` 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

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).