From max@momoland.openchat.com Fri Jun 20 10:50:58 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-3.6 required=4.0 tests=BAYES_00,FOURLA, IMPRONONCABLE_1,MURPHY_WRONG_WORD1,MURPHY_WRONG_WORD2,RCVD_IN_DNSWL_LOW autolearn=no version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 20 Jun 2008 17:50:59 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m5KHoseh031504 for ; Fri, 20 Jun 2008 10:50:56 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K9klC-0000kc-DF for bug-gnu-emacs@gnu.org; Fri, 20 Jun 2008 13:50:54 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K9klC-0000k7-1S for bug-gnu-emacs@gnu.org; Fri, 20 Jun 2008 13:50:54 -0400 Received: from [199.232.76.173] (port=49490 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K9klB-0000jg-HU for bug-gnu-emacs@gnu.org; Fri, 20 Jun 2008 13:50:53 -0400 Received: from p84-72.acedsl.com ([66.114.84.72]:27399 helo=momoland.openchat.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K9klA-0003Ny-85 for bug-gnu-emacs@gnu.org; Fri, 20 Jun 2008 13:50:52 -0400 Received: by momoland.openchat.com (Postfix, from userid 1000) id 4FC98F40D9C3; Fri, 20 Jun 2008 13:18:28 -0400 (EDT) From: Max Mikhanosha To: bug-gnu-emacs@gnu.org Subject: file-precious-flag overwrites symlinks Message-Id: <20080620171828.4FC98F40D9C3@momoland.openchat.com> Date: Fri, 20 Jun 2008 13:18:28 -0400 (EDT) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-Greylist: delayed 1942 seconds by postgrey-1.27 at monty-python; Fri, 20 Jun 2008 13:50:51 EDT I keep my .emacs file under version control as part of overall collection of config files, and as result ~/.emacs is a symbolic link. `backup-by-copying-when-linked' is set to t, so visiting ~/.emacs and then editing and saving it correctly saves the file that symlink is pointing too. For a long time I was trying to track down why sometimes, my ~/.emacs symbolic link is suddenly overwritten by the actual file. Finally found that this happens when one uses "Save for future session" in customize package, and farther tracked it down to a behavior of `basic-save-buffer-2' when file-precious-flag is set. Test case: -rw-r--r-- 1 max users 4 Jun 20 12:57 file lrwxrwxrwx 1 max users 4 Jun 20 12:58 link -> file backup-by-copying-when-linked => t file-precious-flag => nil Visit "link" edit and save -rw-r--r-- 1 max users 14 Jun 20 12:59 file lrwxrwxrwx 1 max users 4 Jun 20 12:58 link -> file Everything fine.. backup-by-copying-when-linked => t file-precious-flag => t Visit "link" edit and save -rw-r--r-- 1 max users 14 Jun 20 12:59 file -rw-r--r-- 1 max users 24 Jun 20 13:00 link Overwrites symlink The offending code in basic-save-buffer-2 is: ;; We succeeded in writing the temp file ;; so rename it. (rename-file tempname buffer-file-name t)) Above should refer to buffer-file-truename IMHO. The documentation for file-precious-flag mentiones that it will break hardlinks, but does not mention that it will break symlinks. If this behavour is not a bug, then maybe its a bug for custom-save-all to set file-precious-flag, causing an suprise to the user as to why ~/.emacs symlink is getting overwritten. In GNU Emacs 22.2.1 (x86_64-suse-linux-gnu, GTK+ Version 2.10.6) of 2008-04-09 on momoland configured using `configure '--with-gcc' '--with-pop' '--without-hesiod' '--with-kerberos' '--with-kerberos5' '--with-leim' '--with-xim' '--with-system-malloc' '--prefix=/usr' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--with-x' '--with-sound' '--with-xpm' '--with-jpeg' '--with-tiff' '--with-gif' '--with-png' '--with-x-toolkit=gtk' '--x-includes=/usr/include' '--x-libraries=/usr/lib64:/usr/share/X11' '--build=x86_64-suse-linux-gnu' 'build_alias=x86_64-suse-linux-gnu' 'CC=gcc' 'CFLAGS=-O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -std=gnu89 -pipe -fno-strict-aliasing -Wno-pointer-sign -Wno-unused-variable -Wno-unused-label -DSYSTEM_PURESIZE_EXTRA=55000 -DSITELOAD_PURESIZE_EXTRA=10000 ' 'LDFLAGS='' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: C locale-coding-system: nil default-enable-multibyte-characters: t Major mode: Fundamental Minor modes in effect: mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t unify-8859-on-encoding-mode: t utf-translate-cjk-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-x C-f C-g i i C-x C-f C-g C-x C-b * C-x o ESC O B RET ( s e t q SPC f i l e DEL DEL DEL DEL DEL DEL DEL DEL DEL DEL M-x - s e DEL DEL DEL s e t - v a r i TAB RET b a c k u p - b y - c o p TAB - TAB l TAB RET t RET C-x C-f l i n k RET o l a l DEL DEL DEL ESC [ 4 ~ ESC [ 4 ~ ESC O B b DEL s o m e SPC t e x t C-x C-x M-x s a v e - b u f DEL DEL DEL DEL TAB - b u f f e r RET M-x s e t - v a r i a b l e RET f i l e - p r e TAB RET t RET RET m o r e SPC t e x t M-x M-p M-p RET C-x b TAB ESC O B ESC O B M-x s u b m i t - b u TAB DEL DEL DEL DEL DEL DEL DEL DEL DEL r e p o r t - e m TAB RET Recent messages: exchange-point-and-mark: No mark set in this buffer Making completion list... Wrote /home/max/link [2 times] Making completion list... next-history-element: End of history; no next item Quit Loading emacsbug... Loading regexp-opt...done Loading emacsbug...done call-interactively: Text is read-only From cyd@stupidchicken.com Wed Jul 30 15:54:18 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-2.4 required=4.0 tests=AWL,BAYES_00,IMPRONONCABLE_1, MURPHY_WRONG_WORD1,MURPHY_WRONG_WORD2 autolearn=no version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 454) by emacsbugs.donarmstrong.com; 30 Jul 2008 22:54:19 +0000 Received: from cyd (CYD.MIT.EDU [18.115.2.24]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m6UMsGHI032199 for <454@emacsbugs.donarmstrong.com>; Wed, 30 Jul 2008 15:54:17 -0700 Received: by cyd (Postfix, from userid 1000) id 5EE2E57E323; Wed, 30 Jul 2008 18:56:16 -0400 (EDT) From: Chong Yidong To: Max Mikhanosha Cc: 454@debbugs.gnu.org Subject: Re: file-precious-flag overwrites symlinks Date: Wed, 30 Jul 2008 18:56:16 -0400 Message-ID: <87zlnzq8vj.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > I keep my .emacs file under version control as part of overall > collection of config files, and as result ~/.emacs is a symbolic > link. > > `backup-by-copying-when-linked' is set to t, so visiting ~/.emacs > and then editing and saving it correctly saves the file that > symlink is pointing too. > > For a long time I was trying to track down why sometimes, my ~/.emacs > symbolic link is suddenly overwritten by the actual file. > > Finally found that this happens when one uses "Save for future > session" in customize package, and farther tracked it down to a > behavior of `basic-save-buffer-2' when file-precious-flag is set. Setting file-precious-flag to t in custom-save-all shouldn't be a problem, because the custom file is visited using find-file-visit-truename. I tried to reproduce your problem, without success: $ touch foo $ ln -s foo .emacs $ emacs M-x customize-variable RET sentence-end-double-space RET [Click on Toggle] C-x C-s C-x C-c $ ls -l foo .emacs lrwxrwxrwx 1 cyd cyd 3 2008-07-30 18:54 .emacs -> foo -rw-r--r-- 1 cyd cyd 528 2008-07-30 18:55 foo Could you provide a recipe that shows this problem? From max@openchat.com Thu Jul 31 22:04:12 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-3.1 required=4.0 tests=AWL,BAYES_00,IMPRONONCABLE_1, MURPHY_WRONG_WORD1,MURPHY_WRONG_WORD2,SPF_HELO_PASS autolearn=no version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 454) by emacsbugs.donarmstrong.com; 1 Aug 2008 05:04:12 +0000 Received: from momoland.openchat.com (p84-72.acedsl.com [66.114.84.72]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m71548up029542 for <454@emacsbugs.donarmstrong.com>; Thu, 31 Jul 2008 22:04:10 -0700 Received: from momoland.openchat.com (localhost [127.0.0.1]) by momoland.openchat.com (Postfix) with ESMTP id CFA95F45674B; Fri, 1 Aug 2008 01:04:07 -0400 (EDT) Date: Fri, 01 Aug 2008 01:04:07 -0400 Message-ID: <877ib1wcl4.wl%max@openchat.com> From: Max Mikhanosha To: Chong Yidong Cc: 454@debbugs.gnu.org Subject: Re: file-precious-flag overwrites symlinks In-Reply-To: <87zlnzq8vj.fsf@stupidchicken.com> References: <87zlnzq8vj.fsf@stupidchicken.com> User-Agent: Wanderlust/2.15.3 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.0.51 (x86_64-unknown-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII After playing with it for a little bit, I found that the additional condition is to have ~/.emacs opened in the buffer, it does not matter if its modified or not. So updated steps to reproduce the problem are: 1. Setup ~/.emacs being symlink to real file 2. M-x set-variable backup-by-copying-when-linked to t (this step is not nessesary to reproduce, just to show that his does not fix it) 3. Make sure sure ~/.emacs is not opened in any buffer, customize a variable, and do "Save for future sessions" 4. It saves changes to where file is pointing 5. Now do C-x C-f ~/.emacs 6. Customize variable again, do "Save for future sessions", it now overwrites ~/.emacs link with real file I can reproduce this with 22.2.1 and with latest emacs from CVS. Regards, Max At Wed, 30 Jul 2008 18:56:16 -0400, Chong Yidong wrote: > > > I keep my .emacs file under version control as part of overall > > collection of config files, and as result ~/.emacs is a symbolic > > link. > > > > `backup-by-copying-when-linked' is set to t, so visiting ~/.emacs > > and then editing and saving it correctly saves the file that > > symlink is pointing too. > > > > For a long time I was trying to track down why sometimes, my ~/.emacs > > symbolic link is suddenly overwritten by the actual file. > > > > Finally found that this happens when one uses "Save for future > > session" in customize package, and farther tracked it down to a > > behavior of `basic-save-buffer-2' when file-precious-flag is set. > > Setting file-precious-flag to t in custom-save-all shouldn't be a > problem, because the custom file is visited using > find-file-visit-truename. I tried to reproduce your problem, without > success: > > $ touch foo > $ ln -s foo .emacs > $ emacs > M-x customize-variable RET sentence-end-double-space RET > [Click on Toggle] > C-x C-s > C-x C-c > $ ls -l foo .emacs > > lrwxrwxrwx 1 cyd cyd 3 2008-07-30 18:54 .emacs -> foo > -rw-r--r-- 1 cyd cyd 528 2008-07-30 18:55 foo > > Could you provide a recipe that shows this problem? From cyd@stupidchicken.com Sat Aug 2 14:07:57 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-3.1 required=4.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 454-done) by emacsbugs.donarmstrong.com; 2 Aug 2008 21:07:57 +0000 Received: from cyd (CYD.MIT.EDU [18.115.2.24]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m72L7sgN000727 for <454-done@emacsbugs.donarmstrong.com>; Sat, 2 Aug 2008 14:07:56 -0700 Received: by cyd (Postfix, from userid 1000) id DA85957E337; Sat, 2 Aug 2008 17:08:05 -0400 (EDT) From: Chong Yidong To: Max Mikhanosha Cc: 454-done@debbugs.gnu.org Subject: Re: file-precious-flag overwrites symlinks References: <87zlnzq8vj.fsf@stupidchicken.com> <877ib1wcl4.wl%max@openchat.com> Date: Sat, 02 Aug 2008 17:08:05 -0400 In-Reply-To: <877ib1wcl4.wl%max@openchat.com> (Max Mikhanosha's message of "Fri, 01 Aug 2008 01:04:07 -0400") Message-ID: <87vdyj9lca.fsf@stupidchicken.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii I see the bug now. I've checked in a fix, thanks. From unknown Sat Aug 16 11:09:40 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: $requester Subject: Internal Control Message-Id: bug archived. Date: Sun, 31 Aug 2008 14:24:04 +0000 User-Agent: Fakemail v42.6.9 # A New Hope # A log time ago, in a galaxy far, far away # something happened. # # Magically this resulted in the following # action being taken, but this fake control # message doesn't tell you why it happened # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator