From: Romain Francoise <romain@orebokech.com>
To: emacs-devel@gnu.org
Subject: `with-output-to-string' leaks buffers
Date: Sat, 20 Sep 2008 00:26:17 +0200 [thread overview]
Message-ID: <878wtnlqly.fsf@elegiac.orebokech.com> (raw)
Shouldn't `with-output-to-string' reap the temporary buffer it
creates even if the code it wraps exits nonlocally?
(git.el installs a function in `after-save-hook' which uses this
macro around code that signals an error, and as a result I had a
little more than 250 *string-output* buffers slowing things down
after a few days of uptime...)
2008-09-19 Romain Francoise <romain@orebokech.com>
* subr.el (with-output-to-string): Make sure that the temporary
buffer gets killed.
Index: lisp/subr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.606
diff -u -r1.606 subr.el
--- lisp/subr.el 7 Sep 2008 09:15:43 -0000 1.606
+++ lisp/subr.el 19 Sep 2008 21:56:40 -0000
@@ -2586,12 +2586,13 @@
(declare (indent 0) (debug t))
`(let ((standard-output
(get-buffer-create (generate-new-buffer-name " *string-output*"))))
- (let ((standard-output standard-output))
- ,@body)
- (with-current-buffer standard-output
- (prog1
- (buffer-string)
- (kill-buffer nil)))))
+ (unwind-protect
+ (progn
+ (let ((standard-output standard-output))
+ ,@body)
+ (with-current-buffer standard-output
+ (buffer-string)))
+ (kill-buffer standard-output))))
(defmacro with-local-quit (&rest body)
"Execute BODY, allowing quits to terminate BODY but not escape further.
next reply other threads:[~2008-09-19 22:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-19 22:26 Romain Francoise [this message]
2008-09-22 23:14 ` `with-output-to-string' leaks buffers Glenn Morris
2008-09-23 0:27 ` Stefan Monnier
2008-09-23 17:29 ` Romain Francoise
2008-09-23 18:00 ` Chong Yidong
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=878wtnlqly.fsf@elegiac.orebokech.com \
--to=romain@orebokech.com \
--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).