From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.emacs.bugs Subject: bug#5273: 23.1; format-alist encode vs write-region-post-annotation-function Date: Sun, 27 Dec 2009 11:17:04 +1100 Message-ID: <87eimhi83j.fsf@blah.blah> Reply-To: Kevin Ryde , 5273@debbugs.gnu.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1261874260 15290 80.91.229.12 (27 Dec 2009 00:37:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 27 Dec 2009 00:37:40 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 27 01:37:33 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NOh8W-0001EO-Hr for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Dec 2009 01:37:33 +0100 Original-Received: from localhost ([127.0.0.1]:34584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NOh8W-00082J-PV for geb-bug-gnu-emacs@m.gmane.org; Sat, 26 Dec 2009 19:37:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NOh8S-000826-PI for bug-gnu-emacs@gnu.org; Sat, 26 Dec 2009 19:37:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NOh8O-00081e-AF for bug-gnu-emacs@gnu.org; Sat, 26 Dec 2009 19:37:28 -0500 Original-Received: from [199.232.76.173] (port=39321 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NOh8O-00081b-1V for bug-gnu-emacs@gnu.org; Sat, 26 Dec 2009 19:37:24 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55170) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NOh8N-0002Rh-Ly for bug-gnu-emacs@gnu.org; Sat, 26 Dec 2009 19:37:23 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1NOgyM-0007kF-By; Sat, 26 Dec 2009 19:27:02 -0500 X-Loop: bug-gnu-emacs@gnu.org Mail-Followup-To: Kevin Ryde , 5273@debbugs.gnu.org Resent-From: Kevin Ryde Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Dec 2009 00:27:02 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-Emacs-PR-Message: report 5273 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.126187358729761 (code B ref -1); Sun, 27 Dec 2009 00:27:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Dec 2009 00:26:27 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NOgxm-0007jy-VU for submit@debbugs.gnu.org; Sat, 26 Dec 2009 19:26:27 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NOgxl-0007jp-Pr for submit@debbugs.gnu.org; Sat, 26 Dec 2009 19:26:26 -0500 Original-Received: from mx10.gnu.org ([199.232.76.166]:40213) by fencepost.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NOgxT-0005Xx-2L for submit@debbugs.gnu.org; Sat, 26 Dec 2009 19:26:08 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NOgpP-0001C6-GF for submit@debbugs.gnu.org; Sat, 26 Dec 2009 19:17:49 -0500 Original-Received: from lists.gnu.org ([199.232.76.165]:56919) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NOgpP-0001C2-Bm for submit@debbugs.gnu.org; Sat, 26 Dec 2009 19:17:47 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NOgpP-0000G0-1r for bug-gnu-emacs@gnu.org; Sat, 26 Dec 2009 19:17:47 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NOgpK-0000CX-6u for bug-gnu-emacs@gnu.org; Sat, 26 Dec 2009 19:17:46 -0500 Original-Received: from [199.232.76.173] (port=58901 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NOgpJ-0000CI-Ox for bug-gnu-emacs@gnu.org; Sat, 26 Dec 2009 19:17:41 -0500 Original-Received: from mailout1-6.pacific.net.au ([61.8.2.213]:40712 helo=mailout1.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NOgpI-0001BH-Ut for bug-gnu-emacs@gnu.org; Sat, 26 Dec 2009 19:17:41 -0500 Original-Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.2.162]) by mailout1.pacific.net.au (Postfix) with ESMTP id D61F750E19B for ; Sun, 27 Dec 2009 11:17:34 +1100 (EST) Original-Received: from blah.blah (ppp2BAA.dyn.pacific.net.au [61.8.43.170]) by mailproxy1.pacific.net.au (Postfix) with ESMTP id F11418C13 for ; Sun, 27 Dec 2009 11:17:33 +1100 (EST) Original-Received: from gg by blah.blah with local (Exim 4.71) (envelope-from ) id 1NOgoi-00040T-S5 for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2009 11:17:05 +1100 User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -3.9 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list X-Spam-Score: -4.8 (----) Resent-Date: Sat, 26 Dec 2009 19:27:02 -0500 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:33781 Archived-At: In a format-alist "TO-FN" encode function, the buffer provided to that function to operate on has write-region-post-annotation-function set to `kill-buffer'. This is extremely dangerous, and almost certainly incompatible with past emacs, as it means any write-region done by the encode function will kill the buffer it's operating on, causing it to then mangle some other buffer, quite possibly with no indication that this happened. A write-region in an encode function is likely if the function works by putting data through an external program. I struck this in three of my file formats where I use make-temp-file. (Two for an error files for call-process-region, one because the program needed an actual file to write to, not a pipe etc.) Because make-temp-file does its job by a writing an empty string to the new file, it ran the kill-buffer from write-region-post-annotation-function. I'm was unsure if make-temp-file ought to guard itself against this. My inclination is not. There's an awful lot of read/write hooks and stuff, and to set them so "write a string to a file" means "kill the current buffer" is so unreasonable that there's no point anticipating it in one particular place when so many things will be similarly affected. I couldn't tell what that write-region-post-annotation-function is trying to achieve. If it's to kill the temporary buffer after writing then an unwind-protect would sound far better, or at least apply the kill setting only after running the format-alist encode func. In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5) of 2009-09-14 on raven, modified by Debian configured using `configure '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS='' 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: en_AU value of $XMODIFIERS: nil locale-coding-system: iso-latin-1-unix default-enable-multibyte-characters: t